<p>The problem was that my signature was incorrect. The API for SignerAsync.sign calls the first argument 'hash' so I assumed that my ECDSA signer was receiving precomputed hash but I needed another sha256. Now it works fine.</p>

CC BY-SA 4.0
2023-10-06T10:08:16.837Z
2023-10-06T10:08:16.837Z
btc-explorer
<p>I am trying to create a simple native segwit transaction on bitcoin testnet but it is failing on submit with RPC error -26 which based on the source code is this: <code>RPC_VERIFY_REJECTED             = -26, //!&lt; Transaction or block was rejected by network rules</code></p>
<p>I have created the transaction using PSBT, signed all inputs, finalized and extracted transaction hex which is what I am submitting via HTTP POST to <code>https://blockstream.info/testnet/api/tx</code></p>
<p>Here is the signed transaction:</p>
<p><code>020000000001024aa98a288909cd44fa7abfb3418cacec2978fd41270b7d6917f0b8fecf92d8e80100000000ffffffff8e4777141e8f81b56237980e0380a79432ec3b82862deb34d5ff3efc701b01f80100000000ffffffff01e80300000000000016001472b11f9b893032a316151b457d51614d5be4c2120247304402200e00725946a9d176649d247644626c75d33c2e08566fb735ef036b25d54b9e15022035da9eb7ed15ae036bea2cb01ad0f2d0291c5612abd039fa84b0c4e11265352b0121036123e7fc019fd0883f5957bd47ce1273d28ed950407c1a6686e86d4d3b00405302483045022100a72f331387f666b357fe96eab028b64dcf542d7b07ac326527ab3e4da7d57233022024944bcd1b4eea97657e145f79cbaf819681409a219224fe696bcdf1b8fd39f50121036123e7fc019fd0883f5957bd47ce1273d28ed950407c1a6686e86d4d3b00405300000000</code></p>
<p>I did try to decode &amp; verify here <code>https://live.blockcypher.com/btc/decodetx/</code> and as far as I understand the native segwit format, it looks right. But then I must be missing something. Any pointers would be appreciated</p>

CC BY-SA 4.0
2023-10-05T12:16:26.027Z
You are using the *same* public key to spend *two different outputs* from *two different prior transactions* (both P2WPKH) - is that right? And those two prior outputs sum to >1000 satoshi?
RedGrittyBrick
CC BY-SA 4.0
2023-10-05T12:38:39.070Z
Does this answer your question? [Error 26: mandatory-script-verify-flag-failed (Data push larger than necessary)](https://bitcoin.stackexchange.com/questions/95480/error-26-mandatory-script-verify-flag-failed-data-push-larger-than-necessary)
RedGrittyBrick
CC BY-SA 4.0
2023-10-06T10:05:50.787Z
Thanks @RedGrittyBrick for your suggestions. I am just sending my own UTXOs to myself for test (minus the fee). No problem with that.

The problem was that my signature was incorrect. The API for SignerAsync.sign calls the first argument 'hash' so I assumed that my ECDSA signer was receiving precomputed hash but I needed another sha256. Now it works fine.
btc-explorer
<transactions>
Bitcoin transaction fails on submit (RPC error -26)
btc-explorer
# Bitcoin transaction fails on submit (RPC error -26)

(Asked by: username_0 on 2023-10-05)

I am trying to create a simple native segwit transaction on bitcoin testnet but it is failing on submit with RPC error -26 which based on the source code is this: `RPC_VERIFY_REJECTED = -26, //!< Transaction or block was rejected by network rules`

I have created the transaction using PSBT, signed all inputs, finalized and extracted transaction hex which is what I am submitting via HTTP POST to `https://blockstream.info/testnet/api/tx`

Here is the signed transaction:

`020000000001024aa98a288909cd44fa7abfb3418cacec2978fd41270b7d6917f0b8fecf92d8e80100000000ffffffff8e4777141e8f81b56237980e0380a79432ec3b82862deb34d5ff3efc701b01f80100000000ffffffff01e80300000000000016001472b11f9b893032a316151b457d51614d5be4c2120247304402200e00725946a9d176649d247644626c75d33c2e08566fb735ef036b25d54b9e15022035da9eb7ed15ae036bea2cb01ad0f2d0291c5612abd039fa84b0c4e11265352b0121036123e7fc019fd0883f5957bd47ce1273d28ed950407c1a6686e86d4d3b00405302483045022100a72f331387f666b357fe96eab028b64dcf542d7b07ac326527ab3e4da7d57233022024944bcd1b4eea97657e145f79cbaf819681409a219224fe696bcdf1b8fd39f50121036123e7fc019fd0883f5957bd47ce1273d28ed950407c1a6686e86d4d3b00405300000000`

I did try to decode & verify here `https://live.blockcypher.com/btc/decodetx/` and as far as I understand the native segwit format, it looks right. But then I must be missing something. Any pointers would be appreciated

**Tags:** transactions

> **Comments:**
> **username_1**: You are using the *same* public key to spend *two different outputs* from *two different prior transactions* (both P2WPKH) - is that right? And those two prior outputs sum to >1000 satoshi?  
> **username_1**: Does this answer your question? [Error 26: mandatory-script-verify-flag-failed (Data push larger than necessary)](https://bitcoin.stackexchange.com/questions/95480/error-26-mandatory-script-verify-flag-failed-data-push-larger-than-necessary)  
> **username_0**: Thanks @username_1 for your suggestions. I am just sending my own UTXOs to myself for test (minus the fee). No problem with that.  The problem was that my signature was incorrect. The API for SignerAsync.sign calls the first argument 'hash' so I assumed that my ECDSA signer was receiving precomputed hash but I needed another sha256. Now it works fine.  

---

## 1 answers

### Answer by username_0 on 2023-10-06. Score: 2 | Accepted answer

The problem was that my signature was incorrect. The API for SignerAsync.sign calls the first argument 'hash' so I assumed that my ECDSA signer was receiving precomputed hash but I needed another sha256. Now it works fine.


---

