Closed blockchainguyy closed 6 years ago
Make sure your output script is using your new tx and not the tx from your utxo.
const outputScript = btc
.serializeTransactionOutputs(newTx)
.toString("hex");
Thanks a lot @dhoffmann, it worked.
Hi @dhoffmann,
As by your help I was successfully able to sign the BTC P2SH transaction, But could you please suggest what shall be the changed into the approach or in any method (https://github.com/LedgerHQ/ledgerjs/issues/176). So that I can sign the BCH P2SH transaction. Since the mentioned code is producing the invalid signature when I sign BCH P2SH transaction.
I am using sigHash: 0x41
in case of signing the BCH P2SH transaction. Also its not required in signing the BTC P2SH transaction. But If i try to sign the BCH transaction without this signHash it thows me error TransportStatusError: Ledger device: Invalid data received (0x6a80)
so as to fix this error I had to use the sigHash
.
Please help me out @dhoffmann
Hi, I'm super unclear what @dhoffmann means here - I'm looking at the documentation, and it explicitly calls the splitTransaction right before serialize txn output, here:
const tx1 = btc.splitTransaction("01000000014ea60aeac5252c14291d428915bd7ccd1bfc4af009f4d4dc57ae597ed0420b71010000008a47304402201f36a12c240dbf9e566bc04321050b1984cd6eaf6caee8f02bb0bfec08e3354b022012ee2aeadcbbfd1e92959f57c15c1c6debb757b798451b104665aa3010569b49014104090b15bde569386734abf2a2b99f9ca6a50656627e77de663ca7325702769986cf26cc9dd7fdea0af432c8e2becc867c932e1b9dd742f2a108997c2252e2bdebffffffff0281b72e00000000001976a91472a5d75c8d2d0565b656a5232703b167d50d5a2b88aca0860100000000001976a9144533f5fb9b4817f713c48f0bfe96b9f50c476c9b88ac00000000"); const outputScript = btc.serializeTransactionOutputs(tx1).toString('hex');
Is that not correct? In your example where you say "newTxn" I don't see that in the code anywhere, where is that coming from? I'm experience a similar problem, and I believe I'm having a similar issue. Any help would be appreicated
Hi, I'm also experiencing the same problem. I couldn't figure out where I made the mistake that make my signature invalid.
my question was posted here https://stackoverflow.com/questions/59082832/how-to-sign-bitcoin-psbt-with-ledger.
does anyone have a working example of a code to sign a new transaction?
it'll be helpful if it include:
so that everyone could run the code locally with their own ledger.
Hi @gre
I was receiving Errors while using signatures produced by
signP2SHTransaction
function of@ledgerhq/hw-app-btc
. So I created a script using bitcore-lib to cross check it against the signature produced by Ledger and pinpoint the change causing the Error. I also verified all my input params and found them to be correct.I will detail both scripts here, though I think it is an issue of ledger's signP2SHTransaction function.
I'm using the following dependencies and node
v8.9.3
:I have created a 2 of 2 Multisig address using the following 2 paths of my ledger-
48'/0'/0'/69/0/0
,48'/0'/0'/96/0/0
. I used the following rawTx:I used the following Redeem Script:
Here's the code I used to produce it:
You can decode it here: https://live.blockcypher.com/btc/decodetx/ Here is my ledger's code which is creating a signature for
48'/0'/0'/69/0/0
path:It returns the following Signature when I pass the RedeemScript with the tx:
And I find it strange that when I remove the redeem script param of
signP2SHTransaction
function (which is labelled optional), I get a different signature:But both are unable to sign the transaction in a proper manner and it error while I validate it against the transaction.
I used the following script to find a valid signature using bitcore-lib:
It produces the following valid signature:
I think there is a bug in the current release of ledger, can you please help me.