Bitcoin Forum
November 19, 2024, 04:32:08 AM *
News: Check out the artwork 1Dq created to commemorate this forum's 15th anniversary
 
  Home Help Search Login Register More  
  Show Posts
Pages: [1]
1  Bitcoin / Development & Technical Discussion / Re: Generate and push a raw Bitcoin transaction on: September 04, 2016, 04:29:58 PM
I used the following code to produce a correct signature:

Code:
    
public String sign(String msg, BigInteger d) throws IOException {
        ECDSASigner signer = new ECDSASigner();
        X9ECParameters params = SECNamedCurves.getByName("secp256k1");
        ECDomainParameters ecDomainParameters = new ECDomainParameters(params.getCurve(), params.getG(), params.getN(), params.getH());
        ECPrivateKeyParameters ecPrivateKeyParameters = new ECPrivateKeyParameters(d, ecDomainParameters);
        signer.init(true, ecPrivateKeyParameters);
        BigInteger[] sigs = signer.generateSignature(DatatypeConverter.parseHexBinary(msg));
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        DERSequenceGenerator seq = new DERSequenceGenerator(byteArrayOutputStream);
        seq.addObject(new DERInteger(sigs[0]));
        seq.addObject(new DERInteger(sigs[1]));
        seq.close();
        byte[] bytes = byteArrayOutputStream.toByteArray();
        return DatatypeConverter.printHexBinary(bytes);
}
2  Bitcoin / Development & Technical Discussion / Re: Generate and push a raw Bitcoin transaction on: September 02, 2016, 06:18:52 PM
I was able to push the transaction after signing it via the https://coinb.in/#sign.

It looks like I am generating incorrect signatures.
3  Bitcoin / Development & Technical Discussion / Re: Generate and push a raw Bitcoin transaction on: September 02, 2016, 05:16:24 PM
remove the new lines
Code:
010000000188802ffe48d0f9d2867495e933b1477094ce017f5d6e4204e40f1040ab805c16000000008b483045022100FA512B36C030BAD0868E2679E1B29E32CCE0099DA086F8FD82010DFFF61B79BA02206C00220683E448C29CCE73FCD7F3CD74E3F76582C07F2F0B436EF247C2D2523F014104a75429241bc8c83e0a1c615155e9b984880f16d39b09b28eef464139fb84d8ff507a5d482e8f41cdb5a762436515d310f16b208bdce4ddfb8a30a7236d36a2daffffffff01a0860100000000001976a914c75073b564d6ebce3d5d12d59ab20d44bd10f69f88ac00000000

and try again.

I tried submitting the signed transaction without the new lines via the https://blockchain.info/pushtx but this doesn't solve the issue. I am still getting the
Quote
Script resulted in a non-true stack: []
error.
I have still no idea what is wrong here.

I was able to successfully decode the transaction using the https://blockchain.info/decode-tx:

Code:
{
   "lock_time":0,
   "size":224,
   "inputs":[
      {
         "prev_out":{
            "index":0,
            "hash":"165c80ab40100fe404426e5d7f01ce947047b133e9957486d2f9d048fe2f8088"
         },
         "script":"483045022100fa512b36c030bad0868e2679e1b29e32cce0099da086f8fd82010dfff61b79ba02206c00220683e448c29cce73fcd7f3cd74e3f76582c07f2f0b436ef247c2d2523f014104a75429241bc8c83e0a1c615155e9b984880f16d39b09b28eef464139fb84d8ff507a5d482e8f41cdb5a762436515d310f16b208bdce4ddfb8a30a7236d36a2da"
      }
   ],
   "version":1,
   "vin_sz":1,
   "hash":"2f0343e08470ad7ac70e4c6ba9c44e4e29e82c4ecc76763ddb45cd3e63baa22d",
   "vout_sz":1,
   "out":[
      {
         "script_string":"OP_DUP OP_HASH160 c75073b564d6ebce3d5d12d59ab20d44bd10f69f OP_EQUALVERIFY OP_CHECKSIG",
         "address":"1KAsr5RcApYG1Rk9uLwsHTXvwsyD1FVyFy",
         "value":100000,
         "script":"76a914c75073b564d6ebce3d5d12d59ab20d44bd10f69f88ac"
      }
   ]
}
4  Bitcoin / Development & Technical Discussion / Generate and push a raw Bitcoin transaction on: September 02, 2016, 04:32:12 PM
When I try to push a raw Bitcoin transaction via the blockchain.info API I get the following error message:

Quote
Script resulted in a non-true stack: []

Transaction should send 0.001 Bitcoins with a 0.0005 fee from 1CBzN3YW4h7XRwb5sjpmBSEPmVPa9wHPgD to the 1KAsr5RcApYG1Rk9uLwsHTXvwsyD1FVyFy address.

Unspent output(s) of the 1CBzN3YW4h7XRwb5sjpmBSEPmVPa9wHPgD:
https://blockchain.info/unspent?active=1CBzN3YW4h7XRwb5sjpmBSEPmVPa9wHPgD

Unsigned transaction:

Code:
01000000
01
88802ffe48d0f9d2867495e933b1477094ce017f5d6e4204e40f1040ab805c16
00000000
19
76a9147abd6d64781930ee9abfaa75b0976b45ce9b93ba88ac
ffffffff
01
a086010000000000
19
76a914c75073b564d6ebce3d5d12d59ab20d44bd10f69f88ac
00000000
01000000

Signed transaction:

Code:
01000000
01
88802ffe48d0f9d2867495e933b1477094ce017f5d6e4204e40f1040ab805c16
00000000
8b
483045022100FA512B36C030BAD0868E2679E1B29E32CCE0099DA086F8FD82010DFFF61B79BA02206C00220683E448C29CCE73FCD7F3CD74E3F76582C07F2F0B436EF247C2D2523F014104a75429241bc8c83e0a1c615155e9b984880f16d39b09b28eef464139fb84d8ff507a5d482e8f41cdb5a762436515d310f16b208bdce4ddfb8a30a7236d36a2da
ffffffff
01
a086010000000000
19
76a914c75073b564d6ebce3d5d12d59ab20d44bd10f69f88ac
00000000

Does anyone has an idea why the transaction is incorrect?
Pages: [1]
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!