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

mandatory-script-verify-flag-failed (Script failed an OP_EQUALVERIFY operation) #11

Closed
robinkanters opened this issue Mar 12, 2018 · 1 comment

Comments

@robinkanters
Copy link

robinkanters commented Mar 12, 2018

Building a Dash testnet transaction, but the transaction gets rejected if I broadcast it via this page.

This is the code I'm using to create the transaction:

val sendingAddress = "yWT4E7FKGmDXuGnYQ4BLX8Nvd2KTMEQ6aU"
val receivingAddress = "ybM6VBWqMgYHUDv7PBeN31Kb7NioX9RpHD"
val sendingAddressPrivkey = "[[ REMOVED ]]" // testnet, but still, would be nice to continue using this address 😜

val tx = Transaction(params)

val inputScript = ScriptBuilder.createOutputScript(Address.fromBase58(params, sendingAddress))
assertEquals("DUP HASH160 PUSHDATA(20)[6f21b38d07b1e7c1f1cb02e52d90486d015ce522] EQUALVERIFY CHECKSIG", inputScript.toString())

tx.addInput(Sha256Hash.wrap("c4e841e257ad42e173eeae309df403f0eff6b51dc87a861e5639041ea362b501"), 0, inputScript)
tx.addOutput(Coin.valueOf(1_0000_0000), Address.fromBase58(params, receivingAddress))
tx.addOutput(Coin.valueOf(13_9878_9000), Address.fromBase58(params, sendingAddress))

println(String(Hex.encode(tx.bitcoinSerialize())))

println("From: ${inputScript.getToAddress(params)}")

val privKey = ECKey.fromPrivate(Hex.decode(sendingAddressPrivkey))

tx.clearInputs()
tx.addSignedInput(TransactionOutPoint(
        params, 0, Sha256Hash.wrap("c4e841e257ad42e173eeae309df403f0eff6b51dc87a861e5639041ea362b501")
), inputScript, privKey, Transaction.SigHash.ALL, true)

println(String(Hex.encode(tx.bitcoinSerialize())))

Output:

010000000101b562a31e0439561e867ac81db5f6eff003f49d30aeee73e142ad57e241e8c4000000001976a9146f21b38d07b1e7c1f1cb02e52d90486d015ce52288acffffffff0200e1f505000000001976a914a4d9b8921b90f9febd8a4ccaa62162a809a05f1588ac88d35f53000000001976a9146f21b38d07b1e7c1f1cb02e52d90486d015ce52288ac00000000
From: yWT4E7FKGmDXuGnYQ4BLX8Nvd2KTMEQ6aU
010000000101b562a31e0439561e867ac81db5f6eff003f49d30aeee73e142ad57e241e8c4000000006a473044022018f362b2a6997177dd95bdc5f5e5415183b4629e90481b76b0eef5e5ae80d595022040fb1f370ad2a4db439c321668bbccbc03088040e5ea0c1740ee40d18b5175d1812102a1580b67fdc6337b8575a3f0f7c1fb55bd365454010d728e6156e813aca1d7ecffffffff0200e1f505000000001976a914a4d9b8921b90f9febd8a4ccaa62162a809a05f1588ac88d35f53000000001976a9146f21b38d07b1e7c1f1cb02e52d90486d015ce52288ac00000000

Could this be the same issue as the one in bitcoinj-cash?

@robinkanters
Copy link
Author

robinkanters commented Mar 12, 2018

Derp. Never mind. Parsing the priv key is wrong.

Should've been

val key = DumpedPrivateKey.fromBase58(params, sendingAddressPrivkey).key

Sorry, this can go :)

lateminer pushed a commit to lateminer/dashj that referenced this issue Sep 13, 2018
Update to Bitsend Core 1.2.7.0
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