Author

Topic: Raw transaction with multiple outputs (Read 186 times)

sr. member
Activity: 279
Merit: 435
December 15, 2018, 06:35:32 PM
#3
Thank you !
staff
Activity: 3458
Merit: 6793
Just writing some code
December 15, 2018, 05:39:31 PM
#2
Your scriptPubKey's are incorrect. You are missing the length specifier for the hashes in the scriptPubKey. Your scriptPubKey's should be 76a914c0123db6acc268de513acdbbba06a2ebacb6d56d88ac and 76a914c0123db6acc268de513acdbbba06a2ebacb6d56d88ac. You will need to adjust your transaction accordingly.
sr. member
Activity: 279
Merit: 435
December 15, 2018, 12:32:59 PM
#1
Hi,

After achieved the serialization of a raw (non-segwit) transaction with just one input and one output, I tried with multiple inputs and outputs. I managed to have it working with multiple inputs but I can't figure out how to just add another ouput (for change) without getting
Code:
{'code': -26, 'message': '64: scriptpubkey'}
Here is my transaction serialized and decoded in a JSON-like way :
Code:
b'0100000002ee70fec3a5b90501e2e0074e21f6104b4ea4aceadc9250edc5f527250cc14148000000006b483045022100d52f6f23e0413003a2859892c33215f95475fa229e5bf7e42ce045f38c16eed902205a318926c3d9fac231fce274d82a7d84cf43acfeb71e43672ae213faf72a956301210388d662be197297bb54ad9927dee599f5b6731fbbb1da5c6c007fdb377054d2ffffffffffd8b15aa873de6a5f6ea0ec620083cff1bc5776130955ff44414f833500d5ac6a000000006a47304402207fed467bef68953c903d0f77f92c95e84bf2cf414936110ab89898526e095588022069f49e015aae8aff0f2e38275ca809c1b3bb2cfc48c6be47a6b0fec403ab6ba301210388d662be197297bb54ad9927dee599f5b6731fbbb1da5c6c007fdb377054d2ffffffffff02a0860100000000001876a9c0123db6acc268de513acdbbba06a2ebacb6d56d88ac905f0100000000001876a9c0123db6acc268de513acdbbba06a2ebacb6d56d88ac00000000'
{
 version :  b'01000000' ,
 input_count :  2 ,
 input :
     prev_hash :  b'ee70fec3a5b90501e2e0074e21f6104b4ea4aceadc9250edc5f527250cc14148' ,
     index :  b'00000000' ,
     scriptsig_len :  107 ,
     scriptsig :  b'483045022100d52f6f23e0413003a2859892c33215f95475fa229e5bf7e42ce045f38c16eed902205a318926c3d9fac231fce274d82a7d84cf43acfeb71e43672ae213faf72a956301210388d662be197297bb54ad9927dee599f5b6731fbbb1da5c6c007fdb377054d2ff' ,
     sequence b'ffffffff' ,
 input :
     prev_hash :  b'd8b15aa873de6a5f6ea0ec620083cff1bc5776130955ff44414f833500d5ac6a' ,
     index :  b'00000000' ,
     scriptsig_len :  106 ,
     scriptsig :  b'47304402207fed467bef68953c903d0f77f92c95e84bf2cf414936110ab89898526e095588022069f49e015aae8aff0f2e38275ca809c1b3bb2cfc48c6be47a6b0fec403ab6ba301210388d662be197297bb54ad9927dee599f5b6731fbbb1da5c6c007fdb377054d2ff' ,
     sequence b'ffffffff' ,
 output_count : 2 ,
 output 0 :
     value :  b'a086010000000000' ,
     script_length :  24 ,
     scriptpubkey :  b'76a9c0123db6acc268de513acdbbba06a2ebacb6d56d88ac' ,
 output 1 :
     value :  b'905f010000000000' ,
     script_length :  24 ,
     scriptpubkey :  b'76a9c0123db6acc268de513acdbbba06a2ebacb6d56d88ac' ,
 locktime :  b'00000000' ,
}

I first thought that it was because my change address was the same as the receiver, but even with changing it it did not work :
Code:
b'0100000002ee70fec3a5b90501e2e0074e21f6104b4ea4aceadc9250edc5f527250cc14148000000006b483045022100886d4b487aaba6c5b623e147ca41967c393efd8759489405e03f52457190c7ed022027070735086341b0e67a3add3889911153db4852cb4820dc53b0ccee89ad708101210388d662be197297bb54ad9927dee599f5b6731fbbb1da5c6c007fdb377054d2ffffffffffd8b15aa873de6a5f6ea0ec620083cff1bc5776130955ff44414f833500d5ac6a000000006a47304402201b96c8a2dd20c682188c2801469bad182d1b0ea059af5c9f733b9bb92bcb5f6802201e92feeb2fb98e85b04d712fcb45bff78a80bcf7fedfee66937cfc3a8bad129701210388d662be197297bb54ad9927dee599f5b6731fbbb1da5c6c007fdb377054d2ffffffffff02a0860100000000001876a9c0123db6acc268de513acdbbba06a2ebacb6d56d88ac905f0100000000001876a91c2150951862e39c232e7611280c03f89a84c65688ac00000000'
{
 version :  b'01000000' ,
 input_count :  2 ,
 input :
     prev_hash :  b'ee70fec3a5b90501e2e0074e21f6104b4ea4aceadc9250edc5f527250cc14148' ,
     index :  b'00000000' ,
     scriptsig_len :  107 ,
     scriptsig :  b'483045022100886d4b487aaba6c5b623e147ca41967c393efd8759489405e03f52457190c7ed022027070735086341b0e67a3add3889911153db4852cb4820dc53b0ccee89ad708101210388d662be197297bb54ad9927dee599f5b6731fbbb1da5c6c007fdb377054d2ff' ,
     sequence b'ffffffff' ,
 input :
     prev_hash :  b'd8b15aa873de6a5f6ea0ec620083cff1bc5776130955ff44414f833500d5ac6a' ,
     index :  b'00000000' ,
     scriptsig_len :  106 ,
     scriptsig :  b'47304402201b96c8a2dd20c682188c2801469bad182d1b0ea059af5c9f733b9bb92bcb5f6802201e92feeb2fb98e85b04d712fcb45bff78a80bcf7fedfee66937cfc3a8bad129701210388d662be197297bb54ad9927dee599f5b6731fbbb1da5c6c007fdb377054d2ff' ,
     sequence b'ffffffff' ,
 output_count : 2 ,
 output 0 :
     value :  b'a086010000000000' ,
     script_length :  24 ,
     scriptpubkey :  b'76a9c0123db6acc268de513acdbbba06a2ebacb6d56d88ac' ,
 output 1 :
     value :  b'905f010000000000' ,
     script_length :  24 ,
     scriptpubkey :  b'76a91c2150951862e39c232e7611280c03f89a84c65688ac' ,
 locktime :  b'00000000' ,
}

I can't figure out what's wrong.

Thank you by advance,
Darosior
Jump to: