0

I am getting this error "Not enough signatures: 1 for 2 inputs" always while using create transaction API for BTC,LTC,DASH.

Before few days ago its was working fine. But Now I am getting Error After hitting transaction.

Please Help me out from this.

Response from API:-

{
  "tx": {
    "block_height": -1,
    "block_index": -1,
    "hash": "ccfd3d55f02db753ccd29b0a3a648d409bc974dd2f24bbcc3c07e5a9362813bb",
    "addresses": [
      "1vkfV2m6C6r9dbkbXCpv8Fg2jugXJarm1",
      "1EdZpspFLCu6YvcAbtPsQCe2tP2JyhpxTy"
    ],
    "total": 10000,
    "fees": 26300,
    "size": 126,
    "preference": "high",
    "relayed_by": "35.177.118.140",
    "received": "2019-08-02T06:13:34.972349221Z",
    "ver": 1,
    "double_spend": false,
    "vin_sz": 2,
    "vout_sz": 1,
    "confirmations": 0,
    "inputs": [
      {
        "prev_hash": "261be3b9c33523078ca92b67c48d1f1dfb60e37749982a6a965ebae62812bb36",
        "output_index": 1,
        "output_value": 6300,
        "sequence": 4294967295,
        "addresses": [
          "1vkfV2m6C6r9dbkbXCpv8Fg2jugXJarm1"
        ],
        "script_type": "pay-to-pubkey-hash",
        "age": 587750
      },
      {
        "prev_hash": "dc0856ee2eb1c019dbd8b979059c86c448d13fb401c5ba68e190c19d5c112b25",
        "output_index": 0,
        "output_value": 30000,
        "sequence": 4294967295,
        "addresses": [
          "1vkfV2m6C6r9dbkbXCpv8Fg2jugXJarm1"
        ],
        "script_type": "pay-to-pubkey-hash",
        "age": 587872
      }
    ],
    "outputs": [
      {
        "value": 10000,
        "script": "76a914958402d8b99f6a3a3e9a252c3c7e9c07ca9840da88ac",
        "addresses": [
          "1EdZpspFLCu6YvcAbtPsQCe2tP2JyhpxTy"
        ],
        "script_type": "pay-to-pubkey-hash"
      }
    ]
  },
  "tosign": [
    "015327ccd713ab76908cbf5631efe1f3f63a5622abb6bff91e14269cd6252cdb",
    "2daa5d0565e6c1df62705b0b6a34cf38221fca5cd123c2c2cf7e0af866d67ed7"
  ],
  "signatures": [
    ""
  ],
  "pubkeys": [
    ""
  ]
}
stdClass Object ( [error] => Not enough signatures: 1 for 2 inputs )

Please check the code :-

$sell_btcbt = '10000';//10000
$sellbtcadd='1EdZpspFLCu6YvcAbtPsQCe2tP2JyhpxTy';
$btccurrentaddress = '13WMhJwu4FUmz3HjXrB3MWZ3TDstdcHe3L';
    $transact_data = '{"inputs":[{"addresses": ["'. $btccurrentaddress .'"]}],"outputs":[{"addresses": ["'. $sellbtcadd .'"], "value": '.$sell_btcbt.'}]}';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.blockcypher.com/v1/btc/main/txs/new?token=1a9daeb78d924879a1d5a84391b6daef&sd=");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $transact_data); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
$blockcypher_tx1 = curl_exec($ch);

$blockcypher_tx =(json_decode($blockcypher_tx1));
    if($blockcypher_tx == '' || empty($blockcypher_tx)){
    echo 'Error on creating blockcypher transaction';
    die;
}

$to_sign1 = $blockcypher_tx->tosign[0];
$private_key = '';
$cmd = getcwd()."/signer $to_sign1 $private_key"; 
exec($cmd,$output);
$esda_sign = isset($output[0]) ? $output[0] : "jhkgdjhkfgkdgsklhsdjkghdfhgjkhdfjghjkdfghhdfjklghjklfghldfhgjkdfhgjkdfhgjkdfhgkfhjgklhfjkghjkdfhg";
if($esda_sign == 0){
echo json_encode(array('resp' => 'Error', 'msg' => 'Error to create signature'));
die;
}
$blockcypher_tx->signatures[] = $esda_sign;
$blockcypher_tx->pubkeys[]= '';
$final_string = json_encode($blockcypher_tx,TRUE);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.blockcypher.com/v1/btc/main/txs/send?token=1a9daeb78d924879a1d5a84391b6daef&sd=");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, $final_string); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);     
$push_response = curl_exec($ch);
$push_response = json_decode($push_response);
print_R($push_response);

Thanks in Advance.

  • Can you give a minimal reproducible example? – vincenzopalazzo Jul 31 at 8:39
  • please check the response above in query.I post all the response from API. – Nandni Aug 2 at 6:16
  • I think the problem is in the code for creating the transaction, can you post it? – vincenzopalazzo Aug 2 at 8:38
  • please check code above using curl method I am hitting this api. – Nandni Aug 2 at 9:37
  • Can You please correct me if I am wrong in code.Please check the code in Above query. – Nandni Aug 2 at 12:26

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.