0

I am using the BlockCypher API to work on the Bitcoin testnet. Transaction creation is carried out in 2 stages: New Transaction Endpoint and Send Transaction Endpoint. The first stage consists in the transaction object fields filling by server, the second - in the local signing with a private key. This error occurs in my second stage:

{
   "errors":[
      {
         "error":"Error validating generated transaction: Error running script for input 0 referencing 5efa3d59dbdd391d8f8d277c49c6d9de7ae13f004190b8132ed6da203e14016b at 0: Script was NOT verified successfully."
      }
   ],
   "tx":{
      "block_height":-1,
      "block_index":-1,
      "hash":"f2b24467c1caa3181ab7effc8b23624c341d6f296fcb5bd4c49026ecc5b138e4",
      "addresses":[
         "mp9Cz49v2Nj2dfSmu4Lz9r91X1CF6hVHVz",
         "mwpG4fa4B3vSio81QEVPiDmA2Cgi26cnV4"
      ],
      "total":88900,
      "fees":11100,
      "size":226,
      "vsize":226,
      "preference":"low",
      "relayed_by":"92.101.184.223",
      "received":"2021-03-29T14:18:34.039933202Z",
      "ver":1,
      "double_spend":false,
      "vin_sz":1,
      "vout_sz":2,
      "confirmations":0,
      "inputs":[
         {
            "prev_hash":"5efa3d59dbdd391d8f8d277c49c6d9de7ae13f004190b8132ed6da203e14016b",
            "output_index":0,
            "script":"483045022100b83a6e3b3b3b997f83fd4ab13f4b1cbabdb69b883e96bbe97443889556b7523702200d2c4ee2e641e31b6f1ce2e20e2fda9bdedca21a668152d15471e040d542aede0121034593cfafe3723ff0396291415e5bc90ef46a1e5967af3fcaaeeb74420c2a72a4",
            "output_value":100000,
            "sequence":4294967295,
            "addresses":[
               "mp9Cz49v2Nj2dfSmu4Lz9r91X1CF6hVHVz"
            ],
            "script_type":"pay-to-pubkey-hash",
            "age":1968449
         }
      ],
      "outputs":[
         {
            "value":50000,
            "script":"76a914b2c7eab66c1e7b1326e228ec7883ef055c21ce1488ac",
            "addresses":[
               "mwpG4fa4B3vSio81QEVPiDmA2Cgi26cnV4"
            ],
            "script_type":"pay-to-pubkey-hash"
         },
         {
            "value":38900,
            "script":"76a9145e9c3e438a489470ed2e8cca4bbb96501f2a827b88ac",
            "addresses":[
               "mp9Cz49v2Nj2dfSmu4Lz9r91X1CF6hVHVz"
            ],
            "script_type":"pay-to-pubkey-hash"
         }
      ]
   },
   "tosign":[
      ""
   ]
}

I am using the Sign method from here. Tell me how to fix the error and, preferably, use the NBitcoin library, since it is already included in the project in order to generate Bitcoin addresses.

TXSkeleton unsignedTx = JsonConvert.DeserializeObject<TXSkeleton>(
    response.Content.ReadAsStringAsync().Result);

unsignedTx.PubKeys = new List<string>();
unsignedTx.Signatures = new List<string>();
Sign(unsignedTx, address.PrivateKey.ToHex(), true, true, true);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.