Bitcoin Forum
April 25, 2024, 07:08:12 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Generate and push a raw Bitcoin transaction  (Read 1126 times)
LibertyFund (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


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

Posts: 1714072092

View Profile Personal Message (Offline)

Ignore
1714072092
Reply with quote  #2

1714072092
Report to moderator
1714072092
Hero Member
*
Offline Offline

Posts: 1714072092

View Profile Personal Message (Offline)

Ignore
1714072092
Reply with quote  #2

1714072092
Report to moderator
1714072092
Hero Member
*
Offline Offline

Posts: 1714072092

View Profile Personal Message (Offline)

Ignore
1714072092
Reply with quote  #2

1714072092
Report to moderator
It is a common myth that Bitcoin is ruled by a majority of miners. This is not true. Bitcoin miners "vote" on the ordering of transactions, but that's all they do. They can't vote to change the network rules.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714072092
Hero Member
*
Offline Offline

Posts: 1714072092

View Profile Personal Message (Offline)

Ignore
1714072092
Reply with quote  #2

1714072092
Report to moderator
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


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

remove the new lines
Code:
010000000188802ffe48d0f9d2867495e933b1477094ce017f5d6e4204e40f1040ab805c16000000008b483045022100FA512B36C030BAD0868E2679E1B29E32CCE0099DA086F8FD82010DFFF61B79BA02206C00220683E448C29CCE73FCD7F3CD74E3F76582C07F2F0B436EF247C2D2523F014104a75429241bc8c83e0a1c615155e9b984880f16d39b09b28eef464139fb84d8ff507a5d482e8f41cdb5a762436515d310f16b208bdce4ddfb8a30a7236d36a2daffffffff01a0860100000000001976a914c75073b564d6ebce3d5d12d59ab20d44bd10f69f88ac00000000

and try again.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
LibertyFund (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


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 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


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 (OP)
Newbie
*
Offline Offline

Activity: 4
Merit: 0


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
Merit: 1019


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

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

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!