Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I using this signature for psbt reedem script? #48

Open
peter-jim opened this issue May 6, 2024 · 0 comments
Open

Can I using this signature for psbt reedem script? #48

peter-jim opened this issue May 6, 2024 · 0 comments

Comments

@peter-jim
Copy link

peter-jim commented May 6, 2024

In bitcoinjs-lib I can easy using alice.sign(signatureHash) to sign after broadcast. If I convert the signature result for hex string it like this d2ffa12c2191ab1197a318b9c90d2007c66c5157b0a1d0238a4ced93116d3b085d5b20e4c54453d85ca0c747c84f73b3449292456a26d2c8354a24c4b26a5359 it is 64 byte buffer , but If I using bitcoinjs-Message I got like this
1f6407f716337d301b7439ff52e37e829f2d35b51589632e575f203bce9ba4cb526a656faf826a417557753a14b397a8d696520b4dd13cd8e1258ec04e2625ddcb ,when I convert to hex string . it is 65 byte buffer, and then I .slice(1) I got 6407f716337d301b7439ff52e37e829f2d35b51589632e575f203bce9ba4cb526a656faf826a417557753a14b397a8d696520b4dd13cd8e1258ec04e2625ddcb it different.

when I broadcast the .slice(1) result buffer I got error withError: mandatory-script-verify-flag-failed (Non-canonical DER signature)

here is my code

const hashType = bitcoin.Transaction.SIGHASH_ALL;
var privateKey = alice.privateKey
var message = '0948924b208d78cdde843cfebf72fdb32f9093f5671b4e09dc8d9371aaa0314f'
var derSignature = bitcoinMessage.sign(message, privateKey, alice.compressed)
console.log('derSignature',derSignature.toString('hex'))

const signatureHash = redeemTx.hashForSignature(0,lockingScript, hashType);  // is 0948924b208d78cdde843cfebf72fdb32f9093f5671b4e09dc8d9371aaa0314f
const signature_bitcoinjs = bitcoin.script.signature.encode(alice.sign(signatureHash), hashType);

const signature_message = bitcoin.script.signature.encode(derSignature.slice(1), hashType);

Can you tell me what reason and how to fix it ? thank you

@peter-jim peter-jim changed the title Can I using this signature for psbt reedm script? Can I using this signature for psbt reedem script? May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant