Bitcoin Forum
October 21, 2017, 11:44:22 PM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: Generate and push a raw Bitcoin transaction  (Read 912 times)
LibertyFund
Newbie
*
Offline Offline

Activity: 4


View Profile
September 02, 2016, 04:32:12 PM
 #1

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?
1508629462
Hero Member
*
Offline Offline

Posts: 1508629462

View Profile Personal Message (Offline)

Ignore
1508629462
Reply with quote  #2

1508629462
Report to moderator
1508629462
Hero Member
*
Offline Offline

Posts: 1508629462

View Profile Personal Message (Offline)

Ignore
1508629462
Reply with quote  #2

1508629462
Report to moderator
1508629462
Hero Member
*
Offline Offline

Posts: 1508629462

View Profile Personal Message (Offline)

Ignore
1508629462
Reply with quote  #2

1508629462
Report to moderator
There are several different types of Bitcoin clients. Server-assisted clients like blockchain.info rely on centralized servers to do their network verification for them. Although the server can't steal the client's bitcoins directly, it can easily execute double-spending-style attacks against the client.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Coding Enthusiast
Sr. Member
****
Offline Offline

Activity: 413


Novice C♯ Coder


View Profile WWW
September 02, 2016, 04:48:00 PM
 #2

remove the new lines
Code:
010000000188802ffe48d0f9d2867495e933b1477094ce017f5d6e4204e40f1040ab805c16000000008b483045022100FA512B36C030BAD0868E2679E1B29E32CCE0099DA086F8FD82010DFFF61B79BA02206C00220683E448C29CCE73FCD7F3CD74E3F76582C07F2F0B436EF247C2D2523F014104a75429241bc8c83e0a1c615155e9b984880f16d39b09b28eef464139fb84d8ff507a5d482e8f41cdb5a762436515d310f16b208bdce4ddfb8a30a7236d36a2daffffffff01a0860100000000001976a914c75073b564d6ebce3d5d12d59ab20d44bd10f69f88ac00000000

and try again.

Projects List+Suggestion box
Donation link using BIP21
BitcoinTransactionTool (0.9.2): Ann - Source Code
Watch Only Bitcoin Wallet (2.2.0): Ann - Source Code
SharpPusher-broadcast transactions (0.10.0): Ann - Source Code

LibertyFund
Newbie
*
Offline Offline

Activity: 4


View Profile
September 02, 2016, 05:16:24 PM
 #3

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"
      }
   ]
}
LibertyFund
Newbie
*
Offline Offline

Activity: 4


View Profile
September 02, 2016, 06:18:52 PM
 #4

I was able to push the transaction after signing it via the https://coinb.in/#sign.

It looks like I am generating incorrect signatures.
LibertyFund
Newbie
*
Offline Offline

Activity: 4


View Profile
September 04, 2016, 04:29:58 PM
 #5

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);
}
amaclin
Legendary
*
Offline Offline

Activity: 1260


View Profile
September 05, 2016, 11:10:28 AM
 #6

use testnet please for debuging your code
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!