edgecase
Author: StJohn Piano
Published: 2020-10-04
Datafeed Article 182
This article has been digitally signed by Edgecase Datafeed.
This article has been digitally signed by its author.
9520 words - 3871 lines - 97 pages




GOAL



Create and sign a Bitcoin transaction with three inputs and three outputs. Add it to the Bitcoin blockchain.

Sub-goals:
- Create a transaction with two inputs and three outputs.
- Create a transaction with three inputs and two outputs.




CONTENTS



- Goal
- Contents
- Brief Summary
- Project Plan
- Notes
- Project Log




BRIEF SUMMARY



Carried out Project Plan 99% successfully.

Minor issue: In transaction Tx6, accidentally set output address to be address A1 instead of A3. This meant that transaction Tx7 transferred bitcoin from A1 (not A3) back to the online exchange account.




PROJECT PLAN



Outline:
- In transaction Tx1, transfer bitcoin from an online exchange account to address A1.
- In transaction Tx2, spend bitcoin from A1, creating two outputs, both of which go to A1.
- In transaction Tx3, spend the two unspent outputs currently in A1, sending them to addresses A2, A3, and A4.
- In transaction Tx4, transfer bitcoin from A2, A3, and A4 to addresses A5, A6, and A7.
- In transaction Tx5, transfer bitcoin from A5, A6, and A7 to addresses A1 and A2.
- In transaction Tx6, transfer bitcoin from A1 and A2 to A3.
- In transaction Tx7, transfer bitcoin from A3 back to the online exchange account.


Details:
- Use Edgecase Bitcoin Storage Toolset version 2 (EBSTv2) to generate 7 Bitcoin private keys and addresses.
- Estimate the transaction fees required for transactions T2-T7.
- Choose an amount to transfer in transaction T1. This amount should be significantly greater than the estimated total transaction fees, so that some tolerance is available for changes in the fee rate during the project.
- Use an online exchange account to transfer this amount of bitcoin to A1. This is transaction T1.
- Use EBSTv2 to create the transactions T2-T7. Wait for each to be mined before creating the next one.
- Various services will be needed when creating the transactions. The types of services are listed on the page Transaction services. I'll record the specific services that I use during the project.






NOTES



Financial information:
- Mined transactions used various fee rates.
- Current BTC/USD exchange rate: 1 BTC ~= 10520 USD.
- T1 sent 0.01 BTC (~105 USD) to address A1.
- T7 returned 0.00935870 BTC (~98.45 USD) to online exchange account.
- Total transaction fees: 0.01 - 0.00935870 = 0.00064130 BTC (~6.75 USD)
- Total size of transactions T2-T7: 2621 bytes
- Estimated total size of transactions T2-T7: 2622 bytes
- Allocated total transaction fees: 2622 bytes * 100 satoshi / byte = 262200 satoshis
= 0.00262200 BTC (~27.58 USD)


Estimated transaction sizes:
- Tx2: 257 bytes
- Tx3: 471 bytes
- Tx4: 651 bytes
- Tx5: 617 bytes
- Tx6: 403 bytes
- Tx7: 223 bytes
Total bytes: 2622


Actual transaction sizes:
- Tx2: 257 bytes
- Tx3: 471 bytes
- Tx4: 651 bytes
- Tx5: 616 bytes
- Tx6: 403 bytes
- Tx7: 223 bytes
Total bytes: 2621















PROJECT LOG





Work machine:
- Name: Judgement
- Windows 10
- Windows Subsystem for Linux (WSL): Ubuntu 16.04
- I'm working in the WSL Ubuntu terminal.




First, download EBSTv2.
- Browse to Edgecase Bitcoin Storage Toolset version 2
- Scroll to the Downloadable Assets section.
- Download all the assets.

List of assets:
- bitcoin_functions_2.py
- bjorn_edstrom_ripemd160.py
- convert_dice_rolls_to_hex_bytes_3.py
- create_nonstandard_transaction_3.py
- create_transaction_3.py
- ecdsa-0.10.tar.gz
- generate_bitcoin_address_4.py
- nonstandard_bitcoin_functions_2.py
- nonstandard_transaction_3.py
- pypy_sha256.py
- transaction_3.py




Create a work directory. Move the EBSTv2 assets into it.




Use this recipe for generating Bitcoin private keys:
Recipe for generating entropy bytes using dice #2

Use this recipe for generating Bitcoin addresses:
Recipe for generating a Bitcoin address #2

Generate 7 private keys and addresses.




New approach to address and private key storage in a text file:
- Call each combination of a private key and an address a "keypair" and give it a keypair number.
- Make three copies of each private key and address, so as to be resilient to typos by default.




Keypair 1 (Kp1):
- Private key 1 (P1):
1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad
1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad
1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad
- Address 1 (A1):
1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
1AppardGrpGdddB2HUTLRd2GGWaYAWDByX


Kp2:
- P2:
ec30b469f5e9b16d565168fbf4c9a60050feab0349ac03ff7611a3a76f2bcd4a
ec30b469f5e9b16d565168fbf4c9a60050feab0349ac03ff7611a3a76f2bcd4a
ec30b469f5e9b16d565168fbf4c9a60050feab0349ac03ff7611a3a76f2bcd4a
- A2:
1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP


Kp3:
- P3:
0f1691d20a6ee40f608b46404b9b42d44ee3599f51ebf48ea7439653044fa3f7
0f1691d20a6ee40f608b46404b9b42d44ee3599f51ebf48ea7439653044fa3f7
0f1691d20a6ee40f608b46404b9b42d44ee3599f51ebf48ea7439653044fa3f7
- A3:
1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L
1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L
1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L


Kp4:
- P4:
9c75fc45b299cf2796809481228d8601dd895f55ffb15f64b583e05bfda3a368
9c75fc45b299cf2796809481228d8601dd895f55ffb15f64b583e05bfda3a368
9c75fc45b299cf2796809481228d8601dd895f55ffb15f64b583e05bfda3a368
- A4:
1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2
1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2
1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2


Kp5:
- P5:
a99c96b4f983d3d0cee414480578f219995a7d8c7dea40a99d83402421a436f3
a99c96b4f983d3d0cee414480578f219995a7d8c7dea40a99d83402421a436f3
a99c96b4f983d3d0cee414480578f219995a7d8c7dea40a99d83402421a436f3
- A5:
1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib
1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib
1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib


Kp6:
- P6:
2f6356a88c432f0149c877553eed29c1aba597dbf59515724f0e001f1adf1556
2f6356a88c432f0149c877553eed29c1aba597dbf59515724f0e001f1adf1556
2f6356a88c432f0149c877553eed29c1aba597dbf59515724f0e001f1adf1556
- A6:
1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD
1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD
1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD


Kp7:
- P7:
153fa0dd919216f4a557d295fb1a8bc3c321ad1492daee35c9eb82227a2d5252
153fa0dd919216f4a557d295fb1a8bc3c321ad1492daee35c9eb82227a2d5252
153fa0dd919216f4a557d295fb1a8bc3c321ad1492daee35c9eb82227a2d5252
- A7:
1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV
1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV
1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV





Let's look at the project outline again.


Outline:
- In transaction Tx1, transfer bitcoin from an online exchange account to address A1.
- In transaction Tx2, spend bitcoin from A1, creating two outputs, both of which go to A1.
- In transaction Tx3, spend the two unspent outputs currently in A1, sending them to addresses A2, A3, and A4.
- In transaction Tx4, transfer bitcoin from A2, A3, and A4 to addresses A5, A6, and A7.
- In transaction Tx5, transfer bitcoin from A5, A6, and A7 to addresses A1 and A2.
- In transaction Tx6, transfer bitcoin from A1 and A2 to A3.
- In transaction Tx7, transfer bitcoin from A3 back to the online exchange account.


List the number of inputs and outputs for each transaction that we will create during this project.
- Tx1: N/A (we don't create this one)
- Tx2: 1 input, 2 outputs
- Tx3: 2 inputs, 3 outputs
- Tx4: 3 inputs, 3 outputs
- Tx5: 3 inputs, 2 outputs
- Tx6: 2 inputs, 1 output
- Tx7: 1 input, 1 output


In the previous project Creating and signing a standard Bitcoin transaction with two inputs and two outputs, I found these estimated sizes:
- Basic 1-input 1-output standard transaction: 223 bytes
- 1 additional input: 180 bytes
- 1 additional output: 34 bytes

Hm. 223 - 180 - 34 = 9
So the base number of bytes (with no inputs and outputs) for a standard transaction is ~9.


Estimate the size of each transaction:
- Tx2: 9 + 1*180 + 2*34 = 257 bytes
- Tx3: 9 + 2*180 + 3*34 = 471 bytes
- Tx4: 9 + 3*180 + 3*34 = 651 bytes
- Tx5: 9 + 3*180 + 2*34 = 617 bytes
- Tx6: 9 + 2*180 + 1*34 = 403 bytes
- Tx7: 9 + 1*180 + 1*34 = 223 bytes


Total bytes:
257 + 471 + 651 + 617 + 403 + 223 = 2622




Use bitcoinfees.earn.com to look up current Bitcoin transaction fee rates.


For inclusion in the next 0-1 blocks, the current fee rate is 100 satoshi / byte.

2622 bytes * 100 satoshi / byte = 262200 satoshis
= 0.00262200 bitcoin

At current BTC/USD exchange rate (1 BTC = ~10520 USD), this is ~27.58 USD.




Choose an amount to transfer in transaction Tx1. This amount should be significantly greater than the estimated total transaction fees, so that some tolerance is available for changes in the fee rate during the project.

I'll transfer about $100 worth of bitcoin. Currently, this is approximately 0.01 BTC.




Log on to Solidi.


Use Solidi to transfer 0.01 BTC to address A1.
1AppardGrpGdddB2HUTLRd2GGWaYAWDByX





Done. Txid:
dcb76b885dd8130a5e926edde743b8cae969449213686313917eb4ccda6bf3cf





Next: Create transaction Tx2, which will transfer bitcoin from A1 to: A1 and A1.




Follow this recipe to create transaction Tx2:
Recipe for creating and signing a standard Bitcoin transaction #2

I'll use a fee of 100 satoshi / byte. Estimated delay: 0-1 blocks (0-50 minutes).

If it isn't mined, I'll use Recipe for managing the fee and broadcast of a Bitcoin transaction #2.



A random 32 byte value ("K" value) is required for making the transaction input signature. Generate a random 32 byte value using this recipe: Recipe for generating entropy bytes using dice #2

K value 1 (K1):
9a1f6aec7c093dd63676f18520cab23c989a387a56ce870b1296510d0b11c7a8


Use Recipe for looking up the unspent outputs in a Bitcoin address #2 to get the details of the unspent output in address A1.


stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX

address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
balance (satoshi): 1000000
balance (bitcoin): 0.01000000
- unspent output 0:
-- txid: dcb76b885dd8130a5e926edde743b8cae969449213686313917eb4ccda6bf3cf
-- previous_output_index: 0
-- satoshi_value: 1000000
-- bitcoin_value: 0.01000000





I've set the controls in the tool create_transaction_3.py as shown below.


	##### START CONTROLS
	# Note: Hex characters in input variable values must be lowercase. 
	random_values = [
		"9a1f6aec7c093dd63676f18520cab23c989a387a56ce870b1296510d0b11c7a8",
	]
	# random_value must be between 1 and 32 bytes. If random_value_type is "raw_bytes", then random_value must be between 1 and 32 ASCII characters. If random_value_type is "hex_bytes", then random_value must be an even number of hex characters and between 2 and 64 hex characters (1 byte is represented by 2 hex characters). 
	# Note: Every ECDSA signature (one for each input in a transaction) requires new random entropy. 
	# random_value_type options: ["raw_bytes", "hex_bytes"]
	random_value_type = "hex_bytes"
	input_data = [
		{
		"txid": "dcb76b885dd8130a5e926edde743b8cae969449213686313917eb4ccda6bf3cf",
		"previous_output_index": "0",
		"private_key_hex": "1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.01", 
		},
	]
	output_data = [
		{
		"address": "1AppardGrpGdddB2HUTLRd2GGWaYAWDByX",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.005", 
		},
		{
		"address": "1AppardGrpGdddB2HUTLRd2GGWaYAWDByX",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.005", 
		},
	]
	# note: all inputs and outputs are assumed to be Pay-To-Public-Key-Hash (P2PKH). 
	change_address = "1AppardGrpGdddB2HUTLRd2GGWaYAWDByX"
	# note: the fee will be subtracted from the amount that is being sent to the change address.
	fee = "" # satoshi
	fee_rate = "100" # satoshi / byte
	# fee_type options: ["fee", "fee_rate"]
	fee_type = "fee_rate"
	##### END CONTROLS





Create and sign the transaction.


stjohn@judgement:work$ python create_transaction_3.py


### START CREATION OF BITCOIN TRANSACTION

- Fee type: fee_rate
- Fee rate: 100.0 (satoshi / byte)
- Number of inputs (i.e. as-yet-unspent outputs): 1
- Number of outputs: 2
- Change address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- Amount to be sent to the change address: 0.005
- Input addresses, with total-value-to-be-sent:
-- 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX: 0.01000000
- Output addresses, with total-value-to-be-received:
-- 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX: 0.01000000
- Total value of all inputs: 0.01000000
- Total value of all outputs: 0.01000000
- Total value of all inputs exactly matches total value of all outputs.
- Estimated transaction size: 257 bytes
- Fee rate: 100.0 (satoshi / byte)
- Calculate 257 * 100.0 and round up to nearest satoshi.
- Final fee: 25700 (satoshi)
- Final fee rate (using estimated transaction size): 100.0000 (satoshi per byte)
- Fee subtracted from amount-to-be-sent-to-change-address.
- New amount to be sent to change address: 474300 (satoshi)
- Size of signed transaction: 257 bytes
- (signed_tx_size - estimated_tx_size): 0 bytes
- Fee rate in signed transaction: 100.0 (satoshi / byte)

Input 0:
Input: {40 bytes unsigned, 66 bytes signable, 179 bytes signed}
- [data] previous_output_hash: cff36bdaccb47e9113636813924469e9cab843e7dd6e925e0a13d85d886bb7dc (32 bytes)
- [data] previous_output_index: 00000000 (4 bytes)
- [signed form] script_length: 8a (1 bytes)
- [signed form] scriptSig: 47304402207da19140017b49a6bd5dad326d4fe21edc0337ef4d5d1415e6aba1e3419a703702204c6617b87383efc3bab4d3b082a350a72754ecd85c7ed6287923cb862615b88d0141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (138 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad (32 bytes)
- [source, goes into scriptSig] public_key_hex: 045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] previous_output_index_int: 0
- [more info] txid: dcb76b885dd8130a5e926edde743b8cae969449213686313917eb4ccda6bf3cf

Output 0:
Output: {34 bytes}
- [data] value: bc3c070000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] bitcoin_amount: 0.00474300
- [more info] satoshi_amount: 474300
- [more info] public_key_hash_hex: 6bc4673483dfe54e2cc83fed2f235cf8102e643d

Output 1:
Output: {34 bytes}
- [data] value: 20a1070000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] bitcoin_amount: 0.005
- [more info] satoshi_amount: 500000
- [more info] public_key_hash_hex: 6bc4673483dfe54e2cc83fed2f235cf8102e643d

Transaction (unsigned form): {118 bytes}
- version: 01000000 (4 bytes)
- input_count: 01 (1 bytes)
- Input 0: {40 bytes}
-- previous_output_hash: cff36bdaccb47e9113636813924469e9cab843e7dd6e925e0a13d85d886bb7dc (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 02 (1 bytes)
- Output 0: {34 bytes}
-- value: bc3c070000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- Output 1: {34 bytes}
-- value: 20a1070000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Transaction (signable form 0): {148 bytes}
- version: 01000000 (4 bytes)
- input_count: 01 (1 bytes)
- Input 0 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: cff36bdaccb47e9113636813924469e9cab843e7dd6e925e0a13d85d886bb7dc (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 02 (1 bytes)
- Output 0: {34 bytes}
-- value: bc3c070000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- Output 1: {34 bytes}
-- value: 20a1070000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signed form): {257 bytes}
- version: 01000000 (4 bytes)
- input_count: 01 (1 bytes)
- Input 0: {179 bytes}
-- previous_output_hash: cff36bdaccb47e9113636813924469e9cab843e7dd6e925e0a13d85d886bb7dc (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 8a (1 bytes)
-- scriptSig: 47304402207da19140017b49a6bd5dad326d4fe21edc0337ef4d5d1415e6aba1e3419a703702204c6617b87383efc3bab4d3b082a350a72754ecd85c7ed6287923cb862615b88d0141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (138 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 02 (1 bytes)
- Output 0: {34 bytes}
-- value: bc3c070000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- Output 1: {34 bytes}
-- value: 20a1070000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Signed transaction:
0100000001cff36bdaccb47e9113636813924469e9cab843e7dd6e925e0a13d85d886bb7dc000000008a47304402207da19140017b49a6bd5dad326d4fe21edc0337ef4d5d1415e6aba1e3419a703702204c6617b87383efc3bab4d3b082a350a72754ecd85c7ed6287923cb862615b88d0141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff02bc3c0700000000001976a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac20a10700000000001976a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac00000000

### END CREATION OF BITCOIN TRANSACTION





Signed transaction Tx2:

0100000001cff36bdaccb47e9113636813924469e9cab843e7dd6e925e0a13d85d886bb7dc000000008a47304402207da19140017b49a6bd5dad326d4fe21edc0337ef4d5d1415e6aba1e3419a703702204c6617b87383efc3bab4d3b082a350a72754ecd85c7ed6287923cb862615b88d0141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff02bc3c0700000000001976a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac20a10700000000001976a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac00000000





Use
live.blockcypher.com/btc/decodetx
to decode Tx2 and confirm that it's formatted correctly.

Use
live.blockcypher.com/btc/pushtx
to broadcast Tx2 to the Bitcoin network.

Result: Txid2 is:
674232a1575e618e4755a17c7b0738f33a81fcb63d5db25d41016a3be18db900





[wait]




Transaction Tx2 now has 6+ confirmations.




Next: Create transaction Tx3, which will transfer bitcoin from A1 and A1 to: A2, A3, and A4. Use the same services that were used during the creation and settlement of Tx2.


I'll use a fee of 20 satoshi / byte. Estimated delay: 2-8 blocks.




Generate two new random K values.

K2:
f8a9a797547e67a8999227187f613b089338f79c6d7447bdaed76a706a52c92c


K3:
4e2924ecd2302f5b702e93f7cba39082fae7ff2fd1619c3368abf70a9869cdcd





Look up the unspent outputs.

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX

address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
balance (satoshi): 974300
balance (bitcoin): 0.00974300
- unspent output 0:
-- txid: 674232a1575e618e4755a17c7b0738f33a81fcb63d5db25d41016a3be18db900
-- previous_output_index: 0
-- satoshi_value: 474300
-- bitcoin_value: 0.00474300
- unspent output 1:
-- txid: 674232a1575e618e4755a17c7b0738f33a81fcb63d5db25d41016a3be18db900
-- previous_output_index: 1
-- satoshi_value: 500000
-- bitcoin_value: 0.00500000





I've set the controls in the tool create_transaction_3.py as shown below.


Note: Not all the value is assigned to an address. The unassigned value will be assigned to the change address, which is set to be address A4.


	##### START CONTROLS
	# Note: Hex characters in input variable values must be lowercase. 
	random_values = [
		"f8a9a797547e67a8999227187f613b089338f79c6d7447bdaed76a706a52c92c",
		"4e2924ecd2302f5b702e93f7cba39082fae7ff2fd1619c3368abf70a9869cdcd",
	]
	# random_value must be between 1 and 32 bytes. If random_value_type is "raw_bytes", then random_value must be between 1 and 32 ASCII characters. If random_value_type is "hex_bytes", then random_value must be an even number of hex characters and between 2 and 64 hex characters (1 byte is represented by 2 hex characters). 
	# Note: Every ECDSA signature (one for each input in a transaction) requires new random entropy. 
	# random_value_type options: ["raw_bytes", "hex_bytes"]
	random_value_type = "hex_bytes"
	input_data = [
		{
		"txid": "674232a1575e618e4755a17c7b0738f33a81fcb63d5db25d41016a3be18db900",
		"previous_output_index": "0",
		"private_key_hex": "1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00474300", 
		},
		{
		"txid": "674232a1575e618e4755a17c7b0738f33a81fcb63d5db25d41016a3be18db900",
		"previous_output_index": "1",
		"private_key_hex": "1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00500000", 
		},
	]
	output_data = [
		{
		"address": "1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.001", 
		},
		{
		"address": "1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.002", 
		},
		{
		"address": "1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.003", 
		},
	]
	# note: all inputs and outputs are assumed to be Pay-To-Public-Key-Hash (P2PKH). 
	change_address = "1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2"
	# note: the fee will be subtracted from the amount that is being sent to the change address.
	fee = "" # satoshi
	fee_rate = "20" # satoshi / byte
	# fee_type options: ["fee", "fee_rate"]
	fee_type = "fee_rate"
	##### END CONTROLS





Create and sign the transaction.


stjohn@judgement:work$ python create_transaction_3.py


### START CREATION OF BITCOIN TRANSACTION

- Fee type: fee_rate
- Fee rate: 20.0 (satoshi / byte)
- Number of inputs (i.e. as-yet-unspent outputs): 2
- Number of outputs: 3
- Change address: 1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2
- Amount to be sent to the change address: 0.003
- Input addresses, with total-value-to-be-sent:
-- 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX: 0.00974300
- Output addresses, with total-value-to-be-received:
-- 1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2: 0.00300000
-- 1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L: 0.00200000
-- 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP: 0.00100000
- Total value of all inputs: 0.00974300
- Total value of all outputs: 0.00600000
- Total value of all inputs is greater than total value of all outputs.
-- Some input value has not been assigned to an output.
-- Extra value: 0.00374300
-- This extra value will be sent to the change address.
-- Change address: 1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2
-- New amount to be sent to change address: 0.00674300
- Estimated transaction size: 470 bytes
- Fee rate: 20.0 (satoshi / byte)
- Calculate 470 * 20.0 and round up to nearest satoshi.
- Final fee: 9400 (satoshi)
- Final fee rate (using estimated transaction size): 20.0000 (satoshi per byte)
- Fee subtracted from amount-to-be-sent-to-change-address.
- New amount to be sent to change address: 664900 (satoshi)
- Size of signed transaction: 471 bytes
- (signed_tx_size - estimated_tx_size): 1 bytes
- Fee rate in signed transaction: 19.958 (satoshi / byte)

Input 0:
Input: {40 bytes unsigned, 66 bytes signable, 179 bytes signed}
- [data] previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
- [data] previous_output_index: 00000000 (4 bytes)
- [signed form] script_length: 8a (1 bytes)
- [signed form] scriptSig: 47304402200bc088521aaba4aa839b34a6f04437a84d16966cdb24c81d72f8279858801bfc022038b0a19f7e65266b3fce2260d07d7d0707e4e2798e6fce7bbed6ddd25fa744f80141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (138 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad (32 bytes)
- [source, goes into scriptSig] public_key_hex: 045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] previous_output_index_int: 0
- [more info] txid: 674232a1575e618e4755a17c7b0738f33a81fcb63d5db25d41016a3be18db900

Input 1:
Input: {40 bytes unsigned, 66 bytes signable, 180 bytes signed}
- [data] previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
- [data] previous_output_index: 01000000 (4 bytes)
- [signed form] script_length: 8b (1 bytes)
- [signed form] scriptSig: 483045022100f879d59fb5e97db6fad01cbc585173801a89e2bc295e67b63e30930e84666137022055bfa081ff5db08bcc2f6dde3df486234f3864767d8af8d5b8c23718dc88750d0141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (139 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad (32 bytes)
- [source, goes into scriptSig] public_key_hex: 045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] previous_output_index_int: 1
- [more info] txid: 674232a1575e618e4755a17c7b0738f33a81fcb63d5db25d41016a3be18db900

Output 0:
Output: {34 bytes}
- [data] value: a086010000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- [more info] address: 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
- [more info] bitcoin_amount: 0.001
- [more info] satoshi_amount: 100000
- [more info] public_key_hash_hex: 898dff254ca0f389679ce68b33ae0c46b992d9f0

Output 1:
Output: {34 bytes}
- [data] value: 400d030000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac (25 bytes)
- [more info] address: 1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L
- [more info] bitcoin_amount: 0.002
- [more info] satoshi_amount: 200000
- [more info] public_key_hash_hex: 6f5302de794fa5b6331e7fe95e895ac8bc328ea8

Output 2:
Output: {34 bytes}
- [data] value: 44250a0000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a914d7ddf94fcd3294570e091b84584b6175413b003888ac (25 bytes)
- [more info] address: 1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2
- [more info] bitcoin_amount: 0.00664900
- [more info] satoshi_amount: 664900
- [more info] public_key_hash_hex: d7ddf94fcd3294570e091b84584b6175413b0038

Transaction (unsigned form): {192 bytes}
- version: 01000000 (4 bytes)
- input_count: 02 (1 bytes)
- Input 0: {40 bytes}
-- previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {40 bytes}
-- previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: a086010000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- Output 1: {34 bytes}
-- value: 400d030000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac (25 bytes)
- Output 2: {34 bytes}
-- value: 44250a0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914d7ddf94fcd3294570e091b84584b6175413b003888ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Transaction (signable form 0): {223 bytes}
- version: 01000000 (4 bytes)
- input_count: 02 (1 bytes)
- Input 0 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {41 bytes}
-- previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: a086010000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- Output 1: {34 bytes}
-- value: 400d030000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac (25 bytes)
- Output 2: {34 bytes}
-- value: 44250a0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914d7ddf94fcd3294570e091b84584b6175413b003888ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signable form 1): {223 bytes}
- version: 01000000 (4 bytes)
- input_count: 02 (1 bytes)
- Input 0: {41 bytes}
-- previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: a086010000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- Output 1: {34 bytes}
-- value: 400d030000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac (25 bytes)
- Output 2: {34 bytes}
-- value: 44250a0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914d7ddf94fcd3294570e091b84584b6175413b003888ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signed form): {471 bytes}
- version: 01000000 (4 bytes)
- input_count: 02 (1 bytes)
- Input 0: {179 bytes}
-- previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 8a (1 bytes)
-- scriptSig: 47304402200bc088521aaba4aa839b34a6f04437a84d16966cdb24c81d72f8279858801bfc022038b0a19f7e65266b3fce2260d07d7d0707e4e2798e6fce7bbed6ddd25fa744f80141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (138 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {180 bytes}
-- previous_output_hash: 00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 8b (1 bytes)
-- scriptSig: 483045022100f879d59fb5e97db6fad01cbc585173801a89e2bc295e67b63e30930e84666137022055bfa081ff5db08bcc2f6dde3df486234f3864767d8af8d5b8c23718dc88750d0141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (139 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: a086010000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- Output 1: {34 bytes}
-- value: 400d030000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac (25 bytes)
- Output 2: {34 bytes}
-- value: 44250a0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914d7ddf94fcd3294570e091b84584b6175413b003888ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Signed transaction:
010000000200b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267000000008a47304402200bc088521aaba4aa839b34a6f04437a84d16966cdb24c81d72f8279858801bfc022038b0a19f7e65266b3fce2260d07d7d0707e4e2798e6fce7bbed6ddd25fa744f80141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267010000008b483045022100f879d59fb5e97db6fad01cbc585173801a89e2bc295e67b63e30930e84666137022055bfa081ff5db08bcc2f6dde3df486234f3864767d8af8d5b8c23718dc88750d0141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff03a0860100000000001976a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac400d0300000000001976a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac44250a00000000001976a914d7ddf94fcd3294570e091b84584b6175413b003888ac00000000

### END CREATION OF BITCOIN TRANSACTION





Signed transaction Tx3:

010000000200b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267000000008a47304402200bc088521aaba4aa839b34a6f04437a84d16966cdb24c81d72f8279858801bfc022038b0a19f7e65266b3fce2260d07d7d0707e4e2798e6fce7bbed6ddd25fa744f80141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff00b98de13b6a01415db25d3db6fc813af338077b7ca155478e615e57a1324267010000008b483045022100f879d59fb5e97db6fad01cbc585173801a89e2bc295e67b63e30930e84666137022055bfa081ff5db08bcc2f6dde3df486234f3864767d8af8d5b8c23718dc88750d0141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff03a0860100000000001976a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac400d0300000000001976a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac44250a00000000001976a914d7ddf94fcd3294570e091b84584b6175413b003888ac00000000





Decode and broadcast Tx3.


Result: Txid3 is:
45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158





[wait]




Transaction Tx3 now has 6+ confirmations.




Next: Create transaction Tx4, which will transfer bitcoin from A2, A3, and A4 to addresses A5, A6, and A7.


I'll use a fee of 20 satoshi / byte. Estimated delay: 3-10 blocks.




Generate three new random K values.

K4:
fbdfc5a68c8bcb354602ab06d8af7d78a016dc897726cc7499bb77e9be27f9d3


K5:
8c5a5c0061ab79d0bb8b918dc521802a6452e861befb307e9a64bc2ed4f3f50e


K6:
0b0f60a63f10ed97c95ab56eff70566edb593bbe366d70d50a74555d1030f4c6





Look up the unspent outputs.

A2:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP

address: 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
balance (satoshi): 100000
balance (bitcoin): 0.00100000
- unspent output 0:
-- txid: 45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158
-- previous_output_index: 0
-- satoshi_value: 100000
-- bitcoin_value: 0.00100000


A3:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L

address: 1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L
balance (satoshi): 200000
balance (bitcoin): 0.00200000
- unspent output 0:
-- txid: 45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158
-- previous_output_index: 1
-- satoshi_value: 200000
-- bitcoin_value: 0.00200000


A4:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2

address: 1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2
balance (satoshi): 664900
balance (bitcoin): 0.00664900
- unspent output 0:
-- txid: 45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158
-- previous_output_index: 2
-- satoshi_value: 664900
-- bitcoin_value: 0.00664900





I've set the controls in the tool create_transaction_3.py as shown below.


	##### START CONTROLS
	# Note: Hex characters in input variable values must be lowercase. 
	random_values = [
		"fbdfc5a68c8bcb354602ab06d8af7d78a016dc897726cc7499bb77e9be27f9d3",
		"8c5a5c0061ab79d0bb8b918dc521802a6452e861befb307e9a64bc2ed4f3f50e",
		"0b0f60a63f10ed97c95ab56eff70566edb593bbe366d70d50a74555d1030f4c6",
	]
	# random_value must be between 1 and 32 bytes. If random_value_type is "raw_bytes", then random_value must be between 1 and 32 ASCII characters. If random_value_type is "hex_bytes", then random_value must be an even number of hex characters and between 2 and 64 hex characters (1 byte is represented by 2 hex characters). 
	# Note: Every ECDSA signature (one for each input in a transaction) requires new random entropy. 
	# random_value_type options: ["raw_bytes", "hex_bytes"]
	random_value_type = "hex_bytes"
	input_data = [
		{
		"txid": "45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158",
		"previous_output_index": "0",
		"private_key_hex": "ec30b469f5e9b16d565168fbf4c9a60050feab0349ac03ff7611a3a76f2bcd4a",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00100000", 
		},
		{
		"txid": "45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158",
		"previous_output_index": "1",
		"private_key_hex": "0f1691d20a6ee40f608b46404b9b42d44ee3599f51ebf48ea7439653044fa3f7",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00200000", 
		},
		{
		"txid": "45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158",
		"previous_output_index": "2",
		"private_key_hex": "9c75fc45b299cf2796809481228d8601dd895f55ffb15f64b583e05bfda3a368",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00664900", 
		},
	]
	output_data = [
		{
		"address": "1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.003", 
		},
		{
		"address": "1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.003", 
		},
		{
		"address": "1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.003", 
		},
	]
	# note: all inputs and outputs are assumed to be Pay-To-Public-Key-Hash (P2PKH). 
	change_address = "1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV"
	# note: the fee will be subtracted from the amount that is being sent to the change address.
	fee = "" # satoshi
	fee_rate = "20" # satoshi / byte
	# fee_type options: ["fee", "fee_rate"]
	fee_type = "fee_rate"
	##### END CONTROLS





Create and sign the transaction.


stjohn@judgement:work$ python create_transaction_3.py


### START CREATION OF BITCOIN TRANSACTION

- Fee type: fee_rate
- Fee rate: 20.0 (satoshi / byte)
- Number of inputs (i.e. as-yet-unspent outputs): 3
- Number of outputs: 3
- Change address: 1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV
- Amount to be sent to the change address: 0.003
- Input addresses, with total-value-to-be-sent:
-- 1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2: 0.00664900
-- 1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L: 0.00200000
-- 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP: 0.00100000
- Output addresses, with total-value-to-be-received:
-- 1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD: 0.00300000
-- 1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib: 0.00300000
-- 1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV: 0.00300000
- Total value of all inputs: 0.00964900
- Total value of all outputs: 0.00900000
- Total value of all inputs is greater than total value of all outputs.
-- Some input value has not been assigned to an output.
-- Extra value: 0.00064900
-- This extra value will be sent to the change address.
-- Change address: 1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV
-- New amount to be sent to change address: 0.00364900
- Estimated transaction size: 649 bytes
- Fee rate: 20.0 (satoshi / byte)
- Calculate 649 * 20.0 and round up to nearest satoshi.
- Final fee: 12980 (satoshi)
- Final fee rate (using estimated transaction size): 20.0000 (satoshi per byte)
- Fee subtracted from amount-to-be-sent-to-change-address.
- New amount to be sent to change address: 351920 (satoshi)
- Size of signed transaction: 651 bytes
- (signed_tx_size - estimated_tx_size): 2 bytes
- Fee rate in signed transaction: 19.939 (satoshi / byte)

Input 0:
Input: {40 bytes unsigned, 66 bytes signable, 180 bytes signed}
- [data] previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
- [data] previous_output_index: 00000000 (4 bytes)
- [signed form] script_length: 8b (1 bytes)
- [signed form] scriptSig: 48304502210090de75947fea4773c8e5ec2b5f61d6d3b43a8eed88d66e6b36c53dca06c0b6100220483d8fb1b2a5721bdbd35db36b059615cc374856551f56cbd96ac99043f873e7014104c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8e (139 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: ec30b469f5e9b16d565168fbf4c9a60050feab0349ac03ff7611a3a76f2bcd4a (32 bytes)
- [source, goes into scriptSig] public_key_hex: 04c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8e (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- [more info] address: 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
- [more info] previous_output_index_int: 0
- [more info] txid: 45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158

Input 1:
Input: {40 bytes unsigned, 66 bytes signable, 180 bytes signed}
- [data] previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
- [data] previous_output_index: 01000000 (4 bytes)
- [signed form] script_length: 8b (1 bytes)
- [signed form] scriptSig: 483045022100a7954bb767cf8d86d4b5a6e8462f8aba8b639020ee492c77ad2667051b30793702203c0d7aeb54204bcf93c23b0d164ec642f95264bb810cabc518f1386b8015636f014104d05610a527029d91535c4c9e9861d9783ca5e7967b3cf61600a9b38cedfed0f2a8d2fe7f2e644652078a9a3da9a372323bb3b7530e0b38ec48b34b2924ffdc0e (139 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 0f1691d20a6ee40f608b46404b9b42d44ee3599f51ebf48ea7439653044fa3f7 (32 bytes)
- [source, goes into scriptSig] public_key_hex: 04d05610a527029d91535c4c9e9861d9783ca5e7967b3cf61600a9b38cedfed0f2a8d2fe7f2e644652078a9a3da9a372323bb3b7530e0b38ec48b34b2924ffdc0e (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac (25 bytes)
- [more info] address: 1B9dT1kcvJqhmF9FpanKbY2vRvNiV6qR2L
- [more info] previous_output_index_int: 1
- [more info] txid: 45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158

Input 2:
Input: {40 bytes unsigned, 66 bytes signable, 179 bytes signed}
- [data] previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
- [data] previous_output_index: 02000000 (4 bytes)
- [signed form] script_length: 8a (1 bytes)
- [signed form] scriptSig: 473044022040b1cc33f8d2e304dc8b345c5c65e29f871278ff694e201421a72ba3b130b54802207249a48acd592ae095efa911cc770e5ca8e4c69b81cc0c2fbeedd5325346b155014104e89d1048d763532481e7dc3ab86ace305c4114e9ce3dfc30f04bc7a4df97adaee3578197f5e1413f9a99dfc99e425344f7bee317762a680b61292e687c12f399 (138 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 9c75fc45b299cf2796809481228d8601dd895f55ffb15f64b583e05bfda3a368 (32 bytes)
- [source, goes into scriptSig] public_key_hex: 04e89d1048d763532481e7dc3ab86ace305c4114e9ce3dfc30f04bc7a4df97adaee3578197f5e1413f9a99dfc99e425344f7bee317762a680b61292e687c12f399 (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a914d7ddf94fcd3294570e091b84584b6175413b003888ac (25 bytes)
- [more info] address: 1LgQCG1DPBpk7Avdex5bSGqyKnxWv6spH2
- [more info] previous_output_index_int: 2
- [more info] txid: 45a69eab1c75342826687d2bea49b49133382622b4cd50783b0e81e49b95d158

Output 0:
Output: {34 bytes}
- [data] value: e093040000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ac (25 bytes)
- [more info] address: 1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib
- [more info] bitcoin_amount: 0.003
- [more info] satoshi_amount: 300000
- [more info] public_key_hash_hex: a17fd96a5a6d76be05542f1a93a263bf02e3b9bc

Output 1:
Output: {34 bytes}
- [data] value: e093040000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988ac (25 bytes)
- [more info] address: 1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD
- [more info] bitcoin_amount: 0.003
- [more info] satoshi_amount: 300000
- [more info] public_key_hash_hex: c5a2a172c3d16db0e2e064d182b4ee9fec533bf9

Output 2:
Output: {34 bytes}
- [data] value: b05e050000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac (25 bytes)
- [more info] address: 1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV
- [more info] bitcoin_amount: 0.00351920
- [more info] satoshi_amount: 351920
- [more info] public_key_hash_hex: 9254f9b4af834fbea8773a6138d2d53e471fcfe1

Transaction (unsigned form): {232 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0: {40 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {40 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2: {40 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ac (25 bytes)
- Output 1: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988ac (25 bytes)
- Output 2: {34 bytes}
-- value: b05e050000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Transaction (signable form 0): {264 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {41 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2: {41 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ac (25 bytes)
- Output 1: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988ac (25 bytes)
- Output 2: {34 bytes}
-- value: b05e050000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signable form 1): {264 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0: {41 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a9146f5302de794fa5b6331e7fe95e895ac8bc328ea888ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2: {41 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ac (25 bytes)
- Output 1: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988ac (25 bytes)
- Output 2: {34 bytes}
-- value: b05e050000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signable form 2): {264 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0: {41 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {41 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a914d7ddf94fcd3294570e091b84584b6175413b003888ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ac (25 bytes)
- Output 1: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988ac (25 bytes)
- Output 2: {34 bytes}
-- value: b05e050000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signed form): {651 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0: {180 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 8b (1 bytes)
-- scriptSig: 48304502210090de75947fea4773c8e5ec2b5f61d6d3b43a8eed88d66e6b36c53dca06c0b6100220483d8fb1b2a5721bdbd35db36b059615cc374856551f56cbd96ac99043f873e7014104c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8e (139 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {180 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 8b (1 bytes)
-- scriptSig: 483045022100a7954bb767cf8d86d4b5a6e8462f8aba8b639020ee492c77ad2667051b30793702203c0d7aeb54204bcf93c23b0d164ec642f95264bb810cabc518f1386b8015636f014104d05610a527029d91535c4c9e9861d9783ca5e7967b3cf61600a9b38cedfed0f2a8d2fe7f2e644652078a9a3da9a372323bb3b7530e0b38ec48b34b2924ffdc0e (139 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2: {179 bytes}
-- previous_output_hash: 58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645 (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length: 8a (1 bytes)
-- scriptSig: 473044022040b1cc33f8d2e304dc8b345c5c65e29f871278ff694e201421a72ba3b130b54802207249a48acd592ae095efa911cc770e5ca8e4c69b81cc0c2fbeedd5325346b155014104e89d1048d763532481e7dc3ab86ace305c4114e9ce3dfc30f04bc7a4df97adaee3578197f5e1413f9a99dfc99e425344f7bee317762a680b61292e687c12f399 (138 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 03 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ac (25 bytes)
- Output 1: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988ac (25 bytes)
- Output 2: {34 bytes}
-- value: b05e050000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Signed transaction:
010000000358d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645000000008b48304502210090de75947fea4773c8e5ec2b5f61d6d3b43a8eed88d66e6b36c53dca06c0b6100220483d8fb1b2a5721bdbd35db36b059615cc374856551f56cbd96ac99043f873e7014104c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8effffffff58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645010000008b483045022100a7954bb767cf8d86d4b5a6e8462f8aba8b639020ee492c77ad2667051b30793702203c0d7aeb54204bcf93c23b0d164ec642f95264bb810cabc518f1386b8015636f014104d05610a527029d91535c4c9e9861d9783ca5e7967b3cf61600a9b38cedfed0f2a8d2fe7f2e644652078a9a3da9a372323bb3b7530e0b38ec48b34b2924ffdc0effffffff58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645020000008a473044022040b1cc33f8d2e304dc8b345c5c65e29f871278ff694e201421a72ba3b130b54802207249a48acd592ae095efa911cc770e5ca8e4c69b81cc0c2fbeedd5325346b155014104e89d1048d763532481e7dc3ab86ace305c4114e9ce3dfc30f04bc7a4df97adaee3578197f5e1413f9a99dfc99e425344f7bee317762a680b61292e687c12f399ffffffff03e0930400000000001976a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ace0930400000000001976a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988acb05e0500000000001976a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac00000000

### END CREATION OF BITCOIN TRANSACTION





Signed transaction Tx4:

010000000358d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645000000008b48304502210090de75947fea4773c8e5ec2b5f61d6d3b43a8eed88d66e6b36c53dca06c0b6100220483d8fb1b2a5721bdbd35db36b059615cc374856551f56cbd96ac99043f873e7014104c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8effffffff58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645010000008b483045022100a7954bb767cf8d86d4b5a6e8462f8aba8b639020ee492c77ad2667051b30793702203c0d7aeb54204bcf93c23b0d164ec642f95264bb810cabc518f1386b8015636f014104d05610a527029d91535c4c9e9861d9783ca5e7967b3cf61600a9b38cedfed0f2a8d2fe7f2e644652078a9a3da9a372323bb3b7530e0b38ec48b34b2924ffdc0effffffff58d1959be4810e3b7850cdb42226383391b449ea2b7d68262834751cab9ea645020000008a473044022040b1cc33f8d2e304dc8b345c5c65e29f871278ff694e201421a72ba3b130b54802207249a48acd592ae095efa911cc770e5ca8e4c69b81cc0c2fbeedd5325346b155014104e89d1048d763532481e7dc3ab86ace305c4114e9ce3dfc30f04bc7a4df97adaee3578197f5e1413f9a99dfc99e425344f7bee317762a680b61292e687c12f399ffffffff03e0930400000000001976a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ace0930400000000001976a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988acb05e0500000000001976a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac00000000





Decode and broadcast Tx4.


Result: Txid4 is:
0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff





[wait]




Transaction Tx4 now has 6+ confirmations.




Next: Create transaction Tx5, which will transfer bitcoin from A5, A6, and A7 to addresses A1 and A2.


I'll use a fee of 20 satoshi / byte. Estimated delay: 3-8 blocks.




Generate three new random K values.

K7:
63f7432e2224571acfdf233c2fb2523fb3e18108af9b2163b4ddbba7f1126af1


K8:
ff458e6414471b906e864cd41b979b653a999d454fb89d2f737cc87cac18c9c0


K9:
9c671cdf96db307eca3d9fd6dbe3b4dad38108058cff5efe99bbc3f538372db9





Look up the unspent outputs.

A5:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib

address: 1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib
balance (satoshi): 300000
balance (bitcoin): 0.00300000
- unspent output 0:
-- txid: 0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff
-- previous_output_index: 0
-- satoshi_value: 300000
-- bitcoin_value: 0.00300000


A6:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD

address: 1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD
balance (satoshi): 300000
balance (bitcoin): 0.00300000
- unspent output 0:
-- txid: 0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff
-- previous_output_index: 1
-- satoshi_value: 300000
-- bitcoin_value: 0.00300000


A7:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV

address: 1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV
balance (satoshi): 351920
balance (bitcoin): 0.00351920
- unspent output 0:
-- txid: 0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff
-- previous_output_index: 2
-- satoshi_value: 351920
-- bitcoin_value: 0.00351920





I've set the controls in the tool create_transaction_3.py as shown below.


	##### START CONTROLS
	# Note: Hex characters in input variable values must be lowercase. 
	random_values = [
		"63f7432e2224571acfdf233c2fb2523fb3e18108af9b2163b4ddbba7f1126af1",
		"ff458e6414471b906e864cd41b979b653a999d454fb89d2f737cc87cac18c9c0",
		"9c671cdf96db307eca3d9fd6dbe3b4dad38108058cff5efe99bbc3f538372db9",
	]
	# random_value must be between 1 and 32 bytes. If random_value_type is "raw_bytes", then random_value must be between 1 and 32 ASCII characters. If random_value_type is "hex_bytes", then random_value must be an even number of hex characters and between 2 and 64 hex characters (1 byte is represented by 2 hex characters). 
	# Note: Every ECDSA signature (one for each input in a transaction) requires new random entropy. 
	# random_value_type options: ["raw_bytes", "hex_bytes"]
	random_value_type = "hex_bytes"
	input_data = [
		{
		"txid": "0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff",
		"previous_output_index": "0",
		"private_key_hex": "a99c96b4f983d3d0cee414480578f219995a7d8c7dea40a99d83402421a436f3",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00300000", 
		},
		{
		"txid": "0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff",
		"previous_output_index": "1",
		"private_key_hex": "2f6356a88c432f0149c877553eed29c1aba597dbf59515724f0e001f1adf1556",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00300000", 
		},
		{
		"txid": "0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff",
		"previous_output_index": "2",
		"private_key_hex": "153fa0dd919216f4a557d295fb1a8bc3c321ad1492daee35c9eb82227a2d5252",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00351920", 
		},
	]
	output_data = [
		{
		"address": "1AppardGrpGdddB2HUTLRd2GGWaYAWDByX",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.003", 
		},
		{
		"address": "1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.006", 
		},
	]
	# note: all inputs and outputs are assumed to be Pay-To-Public-Key-Hash (P2PKH). 
	change_address = "1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP"
	# note: the fee will be subtracted from the amount that is being sent to the change address.
	fee = "" # satoshi
	fee_rate = "20" # satoshi / byte
	# fee_type options: ["fee", "fee_rate"]
	fee_type = "fee_rate"
	##### END CONTROLS





Create and sign the transaction.


stjohn@judgement:work$ python create_transaction_3.py


### START CREATION OF BITCOIN TRANSACTION

- Fee type: fee_rate
- Fee rate: 20.0 (satoshi / byte)
- Number of inputs (i.e. as-yet-unspent outputs): 3
- Number of outputs: 2
- Change address: 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
- Amount to be sent to the change address: 0.006
- Input addresses, with total-value-to-be-sent:
-- 1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD: 0.00300000
-- 1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib: 0.00300000
-- 1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV: 0.00351920
- Output addresses, with total-value-to-be-received:
-- 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX: 0.00300000
-- 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP: 0.00600000
- Total value of all inputs: 0.00951920
- Total value of all outputs: 0.00900000
- Total value of all inputs is greater than total value of all outputs.
-- Some input value has not been assigned to an output.
-- Extra value: 0.00051920
-- This extra value will be sent to the change address.
-- Change address: 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
-- New amount to be sent to change address: 0.00651920
- Estimated transaction size: 615 bytes
- Fee rate: 20.0 (satoshi / byte)
- Calculate 615 * 20.0 and round up to nearest satoshi.
- Final fee: 12300 (satoshi)
- Final fee rate (using estimated transaction size): 20.0000 (satoshi per byte)
- Fee subtracted from amount-to-be-sent-to-change-address.
- New amount to be sent to change address: 639620 (satoshi)
- Size of signed transaction: 616 bytes
- (signed_tx_size - estimated_tx_size): 1 bytes
- Fee rate in signed transaction: 19.968 (satoshi / byte)

Input 0:
Input: {40 bytes unsigned, 66 bytes signable, 180 bytes signed}
- [data] previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
- [data] previous_output_index: 00000000 (4 bytes)
- [signed form] script_length: 8b (1 bytes)
- [signed form] scriptSig: 48304502210091c97b0f3195bad52438436f9a41745364f435171f89700a8744b1d120c63ddf022054ca2c65a57076d4563df23e31f7527290c8518c4671a2cd1e81082ad58c2e660141043b0ce517d5e3206e77f6c7f0c6a2ca264c09202cc34a7036adc391434dfad435eb0fdddb7637dae95c24131adfe2e95faa49365bf7eada7e2e25b09a21f5379e (139 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: a99c96b4f983d3d0cee414480578f219995a7d8c7dea40a99d83402421a436f3 (32 bytes)
- [source, goes into scriptSig] public_key_hex: 043b0ce517d5e3206e77f6c7f0c6a2ca264c09202cc34a7036adc391434dfad435eb0fdddb7637dae95c24131adfe2e95faa49365bf7eada7e2e25b09a21f5379e (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ac (25 bytes)
- [more info] address: 1Fivx1V444aqjY85SxvzsEG5NjYdM6JWib
- [more info] previous_output_index_int: 0
- [more info] txid: 0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff

Input 1:
Input: {40 bytes unsigned, 66 bytes signable, 179 bytes signed}
- [data] previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
- [data] previous_output_index: 01000000 (4 bytes)
- [signed form] script_length: 8a (1 bytes)
- [signed form] scriptSig: 47304402206231487d016d507ec1373caad8404240737b17b08628ea7396bb230c3b7daf020220637e036bc290834962e284fc81e6176baa890c057f713c7884eef264f1dcfe82014104da0f0a2fb16d1c739e05e9d14a6dbc411bd6c31f3cec812e12d7402f6352cc3dee78882fc83a3bccf087c1224798eaa1fefa19c2150db09e860e290414885666 (138 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 2f6356a88c432f0149c877553eed29c1aba597dbf59515724f0e001f1adf1556 (32 bytes)
- [source, goes into scriptSig] public_key_hex: 04da0f0a2fb16d1c739e05e9d14a6dbc411bd6c31f3cec812e12d7402f6352cc3dee78882fc83a3bccf087c1224798eaa1fefa19c2150db09e860e290414885666 (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988ac (25 bytes)
- [more info] address: 1K1zwZscQNA1vsnNzKPdiDpkCmWo4EtWLD
- [more info] previous_output_index_int: 1
- [more info] txid: 0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff

Input 2:
Input: {40 bytes unsigned, 66 bytes signable, 179 bytes signed}
- [data] previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
- [data] previous_output_index: 02000000 (4 bytes)
- [signed form] script_length: 8a (1 bytes)
- [signed form] scriptSig: 47304402203311351244e4c4ecaa8cf006f664d7c1beacf6e5b249b9e37b4fe0a0255db97d02205324c9aeb394dd0323c227f523aad0b37c2d9f8110a8c29a45fd5566102628c50141046ca6bcf1a709667ce9c219df51d8cbb4f6c764a4deeac000613d68f62628739c2ac082421ea0bdf28379c58b3be25d4af6c1cd2216fb4061283d20a9de7f9368 (138 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 153fa0dd919216f4a557d295fb1a8bc3c321ad1492daee35c9eb82227a2d5252 (32 bytes)
- [source, goes into scriptSig] public_key_hex: 046ca6bcf1a709667ce9c219df51d8cbb4f6c764a4deeac000613d68f62628739c2ac082421ea0bdf28379c58b3be25d4af6c1cd2216fb4061283d20a9de7f9368 (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac (25 bytes)
- [more info] address: 1ELjTCk6ESp8gydm2KgeyRgBamgrwppTTV
- [more info] previous_output_index_int: 2
- [more info] txid: 0a4b990b11185bfa8dfa2f29fe51a619abe89f8a3e527416a0cb40f5cdfc96ff

Output 0:
Output: {34 bytes}
- [data] value: e093040000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] bitcoin_amount: 0.003
- [more info] satoshi_amount: 300000
- [more info] public_key_hash_hex: 6bc4673483dfe54e2cc83fed2f235cf8102e643d

Output 1:
Output: {34 bytes}
- [data] value: 84c2090000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- [more info] address: 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
- [more info] bitcoin_amount: 0.00639620
- [more info] satoshi_amount: 639620
- [more info] public_key_hash_hex: 898dff254ca0f389679ce68b33ae0c46b992d9f0

Transaction (unsigned form): {198 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0: {40 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {40 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2: {40 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 02 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- Output 1: {34 bytes}
-- value: 84c2090000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Transaction (signable form 0): {230 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a914a17fd96a5a6d76be05542f1a93a263bf02e3b9bc88ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {41 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2: {41 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 02 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- Output 1: {34 bytes}
-- value: 84c2090000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signable form 1): {230 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0: {41 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a914c5a2a172c3d16db0e2e064d182b4ee9fec533bf988ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2: {41 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 02 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- Output 1: {34 bytes}
-- value: 84c2090000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signable form 2): {230 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0: {41 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {41 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a9149254f9b4af834fbea8773a6138d2d53e471fcfe188ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 02 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- Output 1: {34 bytes}
-- value: 84c2090000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signed form): {616 bytes}
- version: 01000000 (4 bytes)
- input_count: 03 (1 bytes)
- Input 0: {180 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 8b (1 bytes)
-- scriptSig: 48304502210091c97b0f3195bad52438436f9a41745364f435171f89700a8744b1d120c63ddf022054ca2c65a57076d4563df23e31f7527290c8518c4671a2cd1e81082ad58c2e660141043b0ce517d5e3206e77f6c7f0c6a2ca264c09202cc34a7036adc391434dfad435eb0fdddb7637dae95c24131adfe2e95faa49365bf7eada7e2e25b09a21f5379e (139 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {179 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 8a (1 bytes)
-- scriptSig: 47304402206231487d016d507ec1373caad8404240737b17b08628ea7396bb230c3b7daf020220637e036bc290834962e284fc81e6176baa890c057f713c7884eef264f1dcfe82014104da0f0a2fb16d1c739e05e9d14a6dbc411bd6c31f3cec812e12d7402f6352cc3dee78882fc83a3bccf087c1224798eaa1fefa19c2150db09e860e290414885666 (138 bytes)
-- sequence: ffffffff (4 bytes)
- Input 2: {179 bytes}
-- previous_output_hash: ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a (32 bytes)
-- previous_output_index: 02000000 (4 bytes)
-- script_length: 8a (1 bytes)
-- scriptSig: 47304402203311351244e4c4ecaa8cf006f664d7c1beacf6e5b249b9e37b4fe0a0255db97d02205324c9aeb394dd0323c227f523aad0b37c2d9f8110a8c29a45fd5566102628c50141046ca6bcf1a709667ce9c219df51d8cbb4f6c764a4deeac000613d68f62628739c2ac082421ea0bdf28379c58b3be25d4af6c1cd2216fb4061283d20a9de7f9368 (138 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 02 (1 bytes)
- Output 0: {34 bytes}
-- value: e093040000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- Output 1: {34 bytes}
-- value: 84c2090000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Signed transaction:
0100000003ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a000000008b48304502210091c97b0f3195bad52438436f9a41745364f435171f89700a8744b1d120c63ddf022054ca2c65a57076d4563df23e31f7527290c8518c4671a2cd1e81082ad58c2e660141043b0ce517d5e3206e77f6c7f0c6a2ca264c09202cc34a7036adc391434dfad435eb0fdddb7637dae95c24131adfe2e95faa49365bf7eada7e2e25b09a21f5379effffffffff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a010000008a47304402206231487d016d507ec1373caad8404240737b17b08628ea7396bb230c3b7daf020220637e036bc290834962e284fc81e6176baa890c057f713c7884eef264f1dcfe82014104da0f0a2fb16d1c739e05e9d14a6dbc411bd6c31f3cec812e12d7402f6352cc3dee78882fc83a3bccf087c1224798eaa1fefa19c2150db09e860e290414885666ffffffffff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a020000008a47304402203311351244e4c4ecaa8cf006f664d7c1beacf6e5b249b9e37b4fe0a0255db97d02205324c9aeb394dd0323c227f523aad0b37c2d9f8110a8c29a45fd5566102628c50141046ca6bcf1a709667ce9c219df51d8cbb4f6c764a4deeac000613d68f62628739c2ac082421ea0bdf28379c58b3be25d4af6c1cd2216fb4061283d20a9de7f9368ffffffff02e0930400000000001976a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac84c20900000000001976a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac00000000

### END CREATION OF BITCOIN TRANSACTION





Signed transaction Tx5:

0100000003ff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a000000008b48304502210091c97b0f3195bad52438436f9a41745364f435171f89700a8744b1d120c63ddf022054ca2c65a57076d4563df23e31f7527290c8518c4671a2cd1e81082ad58c2e660141043b0ce517d5e3206e77f6c7f0c6a2ca264c09202cc34a7036adc391434dfad435eb0fdddb7637dae95c24131adfe2e95faa49365bf7eada7e2e25b09a21f5379effffffffff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a010000008a47304402206231487d016d507ec1373caad8404240737b17b08628ea7396bb230c3b7daf020220637e036bc290834962e284fc81e6176baa890c057f713c7884eef264f1dcfe82014104da0f0a2fb16d1c739e05e9d14a6dbc411bd6c31f3cec812e12d7402f6352cc3dee78882fc83a3bccf087c1224798eaa1fefa19c2150db09e860e290414885666ffffffffff96fccdf540cba01674523e8a9fe8ab19a651fe292ffa8dfa5b18110b994b0a020000008a47304402203311351244e4c4ecaa8cf006f664d7c1beacf6e5b249b9e37b4fe0a0255db97d02205324c9aeb394dd0323c227f523aad0b37c2d9f8110a8c29a45fd5566102628c50141046ca6bcf1a709667ce9c219df51d8cbb4f6c764a4deeac000613d68f62628739c2ac082421ea0bdf28379c58b3be25d4af6c1cd2216fb4061283d20a9de7f9368ffffffff02e0930400000000001976a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac84c20900000000001976a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac00000000





Decode and broadcast Tx5.


Result: Txid5 is:
10f92ae76b7df85ca3a3dc14e9445e68461fe2d2efad28c91000eb0ac6053411





[wait]




Transaction Tx5 now has 6+ confirmations.




Next: Create transaction Tx6, which will transfer bitcoin from A1 and A2 to A3.


I'll use a fee of 6 satoshi / byte. Estimated delay: 2-10 blocks.




Generate two new random K values.

K10:
2fc30fed4b5e84fed20f4e43d1efc58b2a0970da22e0405690f477f8b9b6d46a


K11:
0d1df243ebf5b19ce72e40319a60992d43c96474315244975267d01cbaa060d4





Look up the unspent outputs.

A1:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX

address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
balance (satoshi): 300000
balance (bitcoin): 0.00300000
- unspent output 0:
-- txid: 10f92ae76b7df85ca3a3dc14e9445e68461fe2d2efad28c91000eb0ac6053411
-- previous_output_index: 0
-- satoshi_value: 300000
-- bitcoin_value: 0.00300000


A2:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP

address: 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
balance (satoshi): 639620
balance (bitcoin): 0.00639620
- unspent output 0:
-- txid: 10f92ae76b7df85ca3a3dc14e9445e68461fe2d2efad28c91000eb0ac6053411
-- previous_output_index: 1
-- satoshi_value: 639620
-- bitcoin_value: 0.00639620





I've set the controls in the tool create_transaction_3.py as shown below.


	##### START CONTROLS
	# Note: Hex characters in input variable values must be lowercase. 
	random_values = [
		"2fc30fed4b5e84fed20f4e43d1efc58b2a0970da22e0405690f477f8b9b6d46a",
		"0d1df243ebf5b19ce72e40319a60992d43c96474315244975267d01cbaa060d4",
	]
	# random_value must be between 1 and 32 bytes. If random_value_type is "raw_bytes", then random_value must be between 1 and 32 ASCII characters. If random_value_type is "hex_bytes", then random_value must be an even number of hex characters and between 2 and 64 hex characters (1 byte is represented by 2 hex characters). 
	# Note: Every ECDSA signature (one for each input in a transaction) requires new random entropy. 
	# random_value_type options: ["raw_bytes", "hex_bytes"]
	random_value_type = "hex_bytes"
	input_data = [
		{
		"txid": "10f92ae76b7df85ca3a3dc14e9445e68461fe2d2efad28c91000eb0ac6053411",
		"previous_output_index": "0",
		"private_key_hex": "1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00300000", 
		},
		{
		"txid": "10f92ae76b7df85ca3a3dc14e9445e68461fe2d2efad28c91000eb0ac6053411",
		"previous_output_index": "1",
		"private_key_hex": "ec30b469f5e9b16d565168fbf4c9a60050feab0349ac03ff7611a3a76f2bcd4a",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00639620", 
		},
	]
	output_data = [
		{
		"address": "1AppardGrpGdddB2HUTLRd2GGWaYAWDByX",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00939620", 
		},
	]
	# note: all inputs and outputs are assumed to be Pay-To-Public-Key-Hash (P2PKH). 
	change_address = "1AppardGrpGdddB2HUTLRd2GGWaYAWDByX"
	# note: the fee will be subtracted from the amount that is being sent to the change address.
	fee = "" # satoshi
	fee_rate = "6" # satoshi / byte
	# fee_type options: ["fee", "fee_rate"]
	fee_type = "fee_rate"
	##### END CONTROLS





Create and sign the transaction.


stjohn@judgement:work$ python create_transaction_3.py


### START CREATION OF BITCOIN TRANSACTION

- Fee type: fee_rate
- Fee rate: 6.0 (satoshi / byte)
- Number of inputs (i.e. as-yet-unspent outputs): 2
- Number of outputs: 1
- Change address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- Amount to be sent to the change address: 0.00939620
- Input addresses, with total-value-to-be-sent:
-- 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX: 0.00300000
-- 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP: 0.00639620
- Output addresses, with total-value-to-be-received:
-- 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX: 0.00939620
- Total value of all inputs: 0.00939620
- Total value of all outputs: 0.00939620
- Total value of all inputs exactly matches total value of all outputs.
- Estimated transaction size: 402 bytes
- Fee rate: 6.0 (satoshi / byte)
- Calculate 402 * 6.0 and round up to nearest satoshi.
- Final fee: 2412 (satoshi)
- Final fee rate (using estimated transaction size): 6.0000 (satoshi per byte)
- Fee subtracted from amount-to-be-sent-to-change-address.
- New amount to be sent to change address: 937208 (satoshi)
- Size of signed transaction: 403 bytes
- (signed_tx_size - estimated_tx_size): 1 bytes
- Fee rate in signed transaction: 5.985 (satoshi / byte)

Input 0:
Input: {40 bytes unsigned, 66 bytes signable, 180 bytes signed}
- [data] previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
- [data] previous_output_index: 00000000 (4 bytes)
- [signed form] script_length: 8b (1 bytes)
- [signed form] scriptSig: 483045022100d7e042d154e661ba62b58454f04ac57b84c93d6df6984c4f814569d5e8d9f87f02203adf0a27a822a55096cb78a8e04ed021796121fddbba63b7686c1c5ebe0daff90141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (139 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad (32 bytes)
- [source, goes into scriptSig] public_key_hex: 045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] previous_output_index_int: 0
- [more info] txid: 10f92ae76b7df85ca3a3dc14e9445e68461fe2d2efad28c91000eb0ac6053411

Input 1:
Input: {40 bytes unsigned, 66 bytes signable, 179 bytes signed}
- [data] previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
- [data] previous_output_index: 01000000 (4 bytes)
- [signed form] script_length: 8a (1 bytes)
- [signed form] scriptSig: 473044022005a57c24dd640ff2f547681872e3f766fd74ee3fa85473443c8a56861945be17022003fd9614906bdf83acfd6a99e8766810d15973398d4d53319c7dc5bf8af48223014104c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8e (138 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: ec30b469f5e9b16d565168fbf4c9a60050feab0349ac03ff7611a3a76f2bcd4a (32 bytes)
- [source, goes into scriptSig] public_key_hex: 04c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8e (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
- [more info] address: 1DYKgP9cMG3wQhgowRJdrE4gRQvz6yMYEP
- [more info] previous_output_index_int: 1
- [more info] txid: 10f92ae76b7df85ca3a3dc14e9445e68461fe2d2efad28c91000eb0ac6053411

Output 0:
Output: {34 bytes}
- [data] value: f84c0e0000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] bitcoin_amount: 0.00937208
- [more info] satoshi_amount: 937208
- [more info] public_key_hash_hex: 6bc4673483dfe54e2cc83fed2f235cf8102e643d

Transaction (unsigned form): {124 bytes}
- version: 01000000 (4 bytes)
- input_count: 02 (1 bytes)
- Input 0: {40 bytes}
-- previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {40 bytes}
-- previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 01 (1 bytes)
- Output 0: {34 bytes}
-- value: f84c0e0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Transaction (signable form 0): {155 bytes}
- version: 01000000 (4 bytes)
- input_count: 02 (1 bytes)
- Input 0 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {41 bytes}
-- previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 01 (1 bytes)
- Output 0: {34 bytes}
-- value: f84c0e0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signable form 1): {155 bytes}
- version: 01000000 (4 bytes)
- input_count: 02 (1 bytes)
- Input 0: {41 bytes}
-- previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 00 (1 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a914898dff254ca0f389679ce68b33ae0c46b992d9f088ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 01 (1 bytes)
- Output 0: {34 bytes}
-- value: f84c0e0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signed form): {403 bytes}
- version: 01000000 (4 bytes)
- input_count: 02 (1 bytes)
- Input 0: {180 bytes}
-- previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 8b (1 bytes)
-- scriptSig: 483045022100d7e042d154e661ba62b58454f04ac57b84c93d6df6984c4f814569d5e8d9f87f02203adf0a27a822a55096cb78a8e04ed021796121fddbba63b7686c1c5ebe0daff90141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (139 bytes)
-- sequence: ffffffff (4 bytes)
- Input 1: {179 bytes}
-- previous_output_hash: 113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910 (32 bytes)
-- previous_output_index: 01000000 (4 bytes)
-- script_length: 8a (1 bytes)
-- scriptSig: 473044022005a57c24dd640ff2f547681872e3f766fd74ee3fa85473443c8a56861945be17022003fd9614906bdf83acfd6a99e8766810d15973398d4d53319c7dc5bf8af48223014104c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8e (138 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 01 (1 bytes)
- Output 0: {34 bytes}
-- value: f84c0e0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Signed transaction:
0100000002113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910000000008b483045022100d7e042d154e661ba62b58454f04ac57b84c93d6df6984c4f814569d5e8d9f87f02203adf0a27a822a55096cb78a8e04ed021796121fddbba63b7686c1c5ebe0daff90141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910010000008a473044022005a57c24dd640ff2f547681872e3f766fd74ee3fa85473443c8a56861945be17022003fd9614906bdf83acfd6a99e8766810d15973398d4d53319c7dc5bf8af48223014104c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8effffffff01f84c0e00000000001976a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac00000000

### END CREATION OF BITCOIN TRANSACTION





Signed transaction Tx6:

0100000002113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910000000008b483045022100d7e042d154e661ba62b58454f04ac57b84c93d6df6984c4f814569d5e8d9f87f02203adf0a27a822a55096cb78a8e04ed021796121fddbba63b7686c1c5ebe0daff90141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff113405c60aeb0010c928adefd2e21f46685e44e914dca3a35cf87d6be72af910010000008a473044022005a57c24dd640ff2f547681872e3f766fd74ee3fa85473443c8a56861945be17022003fd9614906bdf83acfd6a99e8766810d15973398d4d53319c7dc5bf8af48223014104c9e9e0bb9a923e815fdef402b23d92fc751d498832fb5a0cbf349e4deba7d4f55d19020b8a7b84c6c8ea03c1635f6dc15be4163a9a914f017d79541a79b2fa8effffffff01f84c0e00000000001976a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac00000000





Decode and broadcast Tx6.


Result: Txid6 is:
8f23fddd6176059649c4b12eb45d8062748f42dd6b6cab7067aae2cd56776f48





[wait]




Woops. Made a mistake. Forgot to change the output address to be A3 instead of A1.

Ah well. Move forward.




[wait]




Transaction Tx6 now has 6+ confirmations.




Next: Create transaction Tx7, which will transfer bitcoin from A1 back to the online exchange account.


My Solidi deposit address:
1NBXXLc7443x5KFw7k5jbnHBwM1CNGw6ka



I'll use a fee of 6 satoshi / byte. Estimated delay: 2-8 blocks.




Generate a new random K value.

K12:
79d93d141305855969f57329fd34173c2546ad9be09f84f458c9d87bbf12b24c





Look up the unspent outputs.

A1:

stjohn@judgement:work$ python get_unspent_outputs_in_address.py --address 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX

address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
balance (satoshi): 937208
balance (bitcoin): 0.00937208
- unspent output 0:
-- txid: 8f23fddd6176059649c4b12eb45d8062748f42dd6b6cab7067aae2cd56776f48
-- previous_output_index: 0
-- satoshi_value: 937208
-- bitcoin_value: 0.00937208





I've set the controls in the tool create_transaction_3.py as shown below.


	##### START CONTROLS
	# Note: Hex characters in input variable values must be lowercase. 
	random_values = [
		"79d93d141305855969f57329fd34173c2546ad9be09f84f458c9d87bbf12b24c",
	]
	# random_value must be between 1 and 32 bytes. If random_value_type is "raw_bytes", then random_value must be between 1 and 32 ASCII characters. If random_value_type is "hex_bytes", then random_value must be an even number of hex characters and between 2 and 64 hex characters (1 byte is represented by 2 hex characters). 
	# Note: Every ECDSA signature (one for each input in a transaction) requires new random entropy. 
	# random_value_type options: ["raw_bytes", "hex_bytes"]
	random_value_type = "hex_bytes"
	input_data = [
		{
		"txid": "8f23fddd6176059649c4b12eb45d8062748f42dd6b6cab7067aae2cd56776f48",
		"previous_output_index": "0",
		"private_key_hex": "1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00937208", 
		},
	]
	output_data = [
		{
		"address": "1NBXXLc7443x5KFw7k5jbnHBwM1CNGw6ka",
		#"satoshi_amount": "", 
		"bitcoin_amount": "0.00937208", 
		},
	]
	# note: all inputs and outputs are assumed to be Pay-To-Public-Key-Hash (P2PKH). 
	change_address = "1NBXXLc7443x5KFw7k5jbnHBwM1CNGw6ka"
	# note: the fee will be subtracted from the amount that is being sent to the change address.
	fee = "" # satoshi
	fee_rate = "6" # satoshi / byte
	# fee_type options: ["fee", "fee_rate"]
	fee_type = "fee_rate"
	##### END CONTROLS





Create and sign the transaction.


stjohn@judgement:work$ python create_transaction_3.py


### START CREATION OF BITCOIN TRANSACTION

- Fee type: fee_rate
- Fee rate: 6.0 (satoshi / byte)
- Number of inputs (i.e. as-yet-unspent outputs): 1
- Number of outputs: 1
- Change address: 1NBXXLc7443x5KFw7k5jbnHBwM1CNGw6ka
- Amount to be sent to the change address: 0.00937208
- Input addresses, with total-value-to-be-sent:
-- 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX: 0.00937208
- Output addresses, with total-value-to-be-received:
-- 1NBXXLc7443x5KFw7k5jbnHBwM1CNGw6ka: 0.00937208
- Total value of all inputs: 0.00937208
- Total value of all outputs: 0.00937208
- Total value of all inputs exactly matches total value of all outputs.
- Estimated transaction size: 223 bytes
- Fee rate: 6.0 (satoshi / byte)
- Calculate 223 * 6.0 and round up to nearest satoshi.
- Final fee: 1338 (satoshi)
- Final fee rate (using estimated transaction size): 6.0000 (satoshi per byte)
- Fee subtracted from amount-to-be-sent-to-change-address.
- New amount to be sent to change address: 935870 (satoshi)
- Size of signed transaction: 223 bytes
- (signed_tx_size - estimated_tx_size): 0 bytes
- Fee rate in signed transaction: 6.0 (satoshi / byte)

Input 0:
Input: {40 bytes unsigned, 66 bytes signable, 179 bytes signed}
- [data] previous_output_hash: 486f7756cde2aa6770ab6c6bdd428f7462805db42eb1c44996057661ddfd238f (32 bytes)
- [data] previous_output_index: 00000000 (4 bytes)
- [signed form] script_length: 8a (1 bytes)
- [signed form] scriptSig: 4730440220550fa9bc55b09f93770c593f46724b4e604076df8e6be26a06fe240936a4580b0220213ab793d6d1d583aa8794d353b8739729bed96d7127bc08855de9516189c6d50141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (138 bytes)
- [data] sequence: ffffffff (4 bytes)
- [used for signing] private_key_hex: 1647a11df9b9785669d630fa90d6c8242a622a8fc077fb50fc4c52f8391c22ad (32 bytes)
- [source, goes into scriptSig] public_key_hex: 045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (65 bytes)
- [signable form] script_length_scriptPubKey: 19 (1 bytes)
- [signable form] scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
- [more info] address: 1AppardGrpGdddB2HUTLRd2GGWaYAWDByX
- [more info] previous_output_index_int: 0
- [more info] txid: 8f23fddd6176059649c4b12eb45d8062748f42dd6b6cab7067aae2cd56776f48

Output 0:
Output: {34 bytes}
- [data] value: be470e0000000000 (8 bytes)
- [data] script_length: 19 (1 bytes)
- [data] scriptPubKey: 76a914e85847cbba0756cf4b881bd2fc114956fd51b00188ac (25 bytes)
- [more info] address: 1NBXXLc7443x5KFw7k5jbnHBwM1CNGw6ka
- [more info] bitcoin_amount: 0.00935870
- [more info] satoshi_amount: 935870
- [more info] public_key_hash_hex: e85847cbba0756cf4b881bd2fc114956fd51b001

Transaction (unsigned form): {84 bytes}
- version: 01000000 (4 bytes)
- input_count: 01 (1 bytes)
- Input 0: {40 bytes}
-- previous_output_hash: 486f7756cde2aa6770ab6c6bdd428f7462805db42eb1c44996057661ddfd238f (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: [none] (0 bytes)
-- scriptSig: [none] (0 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 01 (1 bytes)
- Output 0: {34 bytes}
-- value: be470e0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914e85847cbba0756cf4b881bd2fc114956fd51b00188ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Transaction (signable form 0): {114 bytes}
- version: 01000000 (4 bytes)
- input_count: 01 (1 bytes)
- Input 0 [to be used to sign this signable form]: {66 bytes}
-- previous_output_hash: 486f7756cde2aa6770ab6c6bdd428f7462805db42eb1c44996057661ddfd238f (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length_scriptPubKey: 19 (1 bytes)
-- scriptPubKey: 76a9146bc4673483dfe54e2cc83fed2f235cf8102e643d88ac (25 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 01 (1 bytes)
- Output 0: {34 bytes}
-- value: be470e0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914e85847cbba0756cf4b881bd2fc114956fd51b00188ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)
- hash_type_4_byte: 01000000 (4 bytes)

Transaction (signed form): {223 bytes}
- version: 01000000 (4 bytes)
- input_count: 01 (1 bytes)
- Input 0: {179 bytes}
-- previous_output_hash: 486f7756cde2aa6770ab6c6bdd428f7462805db42eb1c44996057661ddfd238f (32 bytes)
-- previous_output_index: 00000000 (4 bytes)
-- script_length: 8a (1 bytes)
-- scriptSig: 4730440220550fa9bc55b09f93770c593f46724b4e604076df8e6be26a06fe240936a4580b0220213ab793d6d1d583aa8794d353b8739729bed96d7127bc08855de9516189c6d50141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254 (138 bytes)
-- sequence: ffffffff (4 bytes)
- output_count: 01 (1 bytes)
- Output 0: {34 bytes}
-- value: be470e0000000000 (8 bytes)
-- script_length: 19 (1 bytes)
-- scriptPubKey: 76a914e85847cbba0756cf4b881bd2fc114956fd51b00188ac (25 bytes)
- block_lock_time: 00000000 (4 bytes)

Signed transaction:
0100000001486f7756cde2aa6770ab6c6bdd428f7462805db42eb1c44996057661ddfd238f000000008a4730440220550fa9bc55b09f93770c593f46724b4e604076df8e6be26a06fe240936a4580b0220213ab793d6d1d583aa8794d353b8739729bed96d7127bc08855de9516189c6d50141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff01be470e00000000001976a914e85847cbba0756cf4b881bd2fc114956fd51b00188ac00000000

### END CREATION OF BITCOIN TRANSACTION





Signed transaction Tx7:

0100000001486f7756cde2aa6770ab6c6bdd428f7462805db42eb1c44996057661ddfd238f000000008a4730440220550fa9bc55b09f93770c593f46724b4e604076df8e6be26a06fe240936a4580b0220213ab793d6d1d583aa8794d353b8739729bed96d7127bc08855de9516189c6d50141045141d905ca3f3c688bd1fd9b2d91ffeb7c12082dcfe2674ccf0239d75b0456acdf5a53b153907a14712d1c6743a264488e7705c42229fe4d2365bfcd592ab254ffffffff01be470e00000000001976a914e85847cbba0756cf4b881bd2fc114956fd51b00188ac00000000





Decode and broadcast Tx7.


Result: Txid7 is:
0999dbd016073b440a190f9e919ae98fb4d6e5b46623d79323ffd6a58881c624





[wait]




Transaction Tx7 now has 6+ confirmations.




Good. That's the end of this project.