Thanks a lot for the explanation. It is rely interesting and cool!
Let me clarify my vision.
For example I have an address
https://blockexplorer.com/address/3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7
The address has 4 input tx
ba3141908a631be74dea503c6f0cdbb364e0a28df9d53f0a027b4cdeef673e9d
4c2da413bbeef2f1dd56a3d7e67af11d63eddd97906dd70afdbbcebdf9a589e7
3266dcc46b422d58b273ffd2acaf9dc2e72e26e3ec7fb82f25611341c7aea5d2
6ab8ac462b08b7883d82b69b2e8ae2e3008522ca50302f5c403dbfd16d9dc97b
So as you can see the address has positive balance.
Now, want to spend coins from the address 3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7
Used next command got tx info by address
https://blockexplorer.com/api/txs/?address=3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7{
"pagesTotal": 1,
"txs": [{
"txid": "ba3141908a631be74dea503c6f0cdbb364e0a28df9d53f0a027b4cdeef673e9d",
"version": 1,
"locktime": 378089,
"vin": [{
"txid": "4c2da413bbeef2f1dd56a3d7e67af11d63eddd97906dd70afdbbcebdf9a589e7",
"vout": 1,
"scriptSig": {
"asm": "3045022100b6ef68be26fa70016712b9f7e774d76c41cee9b3dee1b83be62b9f6156f35d0202205f1111cc91ff047fd2cf6cd825813d9dd650efd66a51cca90c2eae24d37aef4701 03b390ee0561e1acda348f3ae8049780e5cb29f6838a49f9b9cca6cd1ed5a34f61",
"hex": "483045022100b6ef68be26fa70016712b9f7e774d76c41cee9b3dee1b83be62b9f6156f35d0202205f1111cc91ff047fd2cf6cd825813d9dd650efd66a51cca90c2eae24d37aef47012103b390ee0561e1acda348f3ae8049780e5cb29f6838a49f9b9cca6cd1ed5a34f61"
},
"sequence": 4294967294,
"n": 0,
"addr": "17UBjxsavEfD5rV14HT67maGRUcEGBkthM",
"valueSat": 13303,
"value": 0.00013303,
"doubleSpentTxID": null
}],
"vout": [{
"value": "0.00001400",
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 a287c1558aec11c6499dea08962cee0144be3eb5 OP_EQUAL",
"hex": "a914a287c1558aec11c6499dea08962cee0144be3eb587",
"reqSigs": 1,
"type": "scripthash",
"addresses": ["3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7"]
}
},
{
"value": "0.00011679",
"n": 1,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 47809e6ee33a3a62574911244832cd0111707bb1 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91447809e6ee33a3a62574911244832cd0111707bb188ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": ["17X54DYtoHnvoDfU2C1GEVCeDGmYUQW4NQ"]
}
}],
"valueOut": 0.00013079,
"size": 224,
"valueIn": 0.00013303,
"fees": 0.00000224
},
{
"txid": "4c2da413bbeef2f1dd56a3d7e67af11d63eddd97906dd70afdbbcebdf9a589e7",
"version": 1,
"locktime": 378096,
"vin": [{
"txid": "3266dcc46b422d58b273ffd2acaf9dc2e72e26e3ec7fb82f25611341c7aea5d2",
"vout": 1,
"scriptSig": {
"asm": "304402204e920f77641fab912bcd360450cd405a991c9c1b6fe0a5783ad56b7031673f6802200bf846877437e259e0afb5eee953ce671af7521967f34d90c3ffd7075546f3c301 02caf284d156a32fbd22c6a6ea47e18c2c1e1075b808968a5a4af0afd3ea907987",
"hex": "47304402204e920f77641fab912bcd360450cd405a991c9c1b6fe0a5783ad56b7031673f6802200bf846877437e259e0afb5eee953ce671af7521967f34d90c3ffd7075546f3c3012102caf284d156a32fbd22c6a6ea47e18c2c1e1075b808968a5a4af0afd3ea907987"
},
"sequence": 4294967294,
"n": 0,
"addr": "1A9E3ck8XzknXG3X9bcsMBhsiUrLDE7DyC",
"valueSat": 14627,
"value": 0.00014627,
"doubleSpentTxID": null
}],
"vout": [{
"value": "0.00001100",
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 a287c1558aec11c6499dea08962cee0144be3eb5 OP_EQUAL",
"hex": "a914a287c1558aec11c6499dea08962cee0144be3eb587",
"reqSigs": 1,
"type": "scripthash",
"addresses": ["3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7"]
}
},
{
"value": "0.00013303",
"n": 1,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 46f4f39bb890190a822610020e86f26dd8e6c6ce OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91446f4f39bb890190a822610020e86f26dd8e6c6ce88ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": ["17UBjxsavEfD5rV14HT67maGRUcEGBkthM"]
},
"spentTxId": "ba3141908a631be74dea503c6f0cdbb364e0a28df9d53f0a027b4cdeef673e9d",
"spentIndex": 0,
"spentTs": 1444374903
}],
"valueOut": 0.00014403,
"size": 223,
"valueIn": 0.00014627,
"fees": 0.00000224
},
{
"txid": "3266dcc46b422d58b273ffd2acaf9dc2e72e26e3ec7fb82f25611341c7aea5d2",
"version": 1,
"locktime": 378096,
"vin": [{
"txid": "6ab8ac462b08b7883d82b69b2e8ae2e3008522ca50302f5c403dbfd16d9dc97b",
"vout": 1,
"scriptSig": {
"asm": "3044022010111b6ba044e80e162929d7969f910fd0924594fd6ca251d6b0623ee4d04cf2022062418189e9fad2381b46624f7e6c8a239668b60f7501a124057ed2e01c04001901 0261095661da1a26d97ddef74e459562705094d0ccc124bff528cb420188251157",
"hex": "473044022010111b6ba044e80e162929d7969f910fd0924594fd6ca251d6b0623ee4d04cf2022062418189e9fad2381b46624f7e6c8a239668b60f7501a124057ed2e01c04001901210261095661da1a26d97ddef74e459562705094d0ccc124bff528cb420188251157"
},
"sequence": 4294967294,
"n": 0,
"addr": "1HwMhJTNhrPSv74oCe8g5otCeidEaHPm9p",
"valueSat": 15851,
"value": 0.00015851,
"doubleSpentTxID": null
}],
"vout": [{
"value": "0.00001000",
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 a287c1558aec11c6499dea08962cee0144be3eb5 OP_EQUAL",
"hex": "a914a287c1558aec11c6499dea08962cee0144be3eb587",
"reqSigs": 1,
"type": "scripthash",
"addresses": ["3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7"]
}
},
{
"value": "0.00014627",
"n": 1,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 64475968d9f6017d8c8066fb7e211f0323f6fb9a OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a91464475968d9f6017d8c8066fb7e211f0323f6fb9a88ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": ["1A9E3ck8XzknXG3X9bcsMBhsiUrLDE7DyC"]
},
"spentTxId": "4c2da413bbeef2f1dd56a3d7e67af11d63eddd97906dd70afdbbcebdf9a589e7",
"spentIndex": 0,
"spentTs": 1444374808
}],
"valueOut": 0.00015627,
"size": 223,
"valueIn": 0.00015851,
"fees": 0.00000224
},
{
"txid": "6ab8ac462b08b7883d82b69b2e8ae2e3008522ca50302f5c403dbfd16d9dc97b",
"version": 1,
"locktime": 378096,
"vin": [{
"txid": "8ff72901bbc42bb9409e0a81f1dc98b31be51cc33c5acb46954964ac30cbbd90",
"vout": 1,
"scriptSig": {
"asm": "304502210083e493b2514b9ecfbb00c05773270b2e8cd902e2863f0edcdefc2790c3670c3e02201a558bda95ec9b6a353732ece8976bf5757f45c96506c79e695ba71823ae94a101 02fcb25d983bb0611e29d7bac1f16b15c7cf44e091fc8d96dae7ecf395bdbd40dc",
"hex": "48304502210083e493b2514b9ecfbb00c05773270b2e8cd902e2863f0edcdefc2790c3670c3e02201a558bda95ec9b6a353732ece8976bf5757f45c96506c79e695ba71823ae94a1012102fcb25d983bb0611e29d7bac1f16b15c7cf44e091fc8d96dae7ecf395bdbd40dc"
},
"sequence": 4294967294,
"n": 0,
"addr": "1749kF8e5X8YRXuqZZa1YJnNfhjEj4aucz",
"valueSat": 16775,
"value": 0.00016775,
"doubleSpentTxID": null
}],
"vout": [{
"value": "0.00000700",
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 a287c1558aec11c6499dea08962cee0144be3eb5 OP_EQUAL",
"hex": "a914a287c1558aec11c6499dea08962cee0144be3eb587",
"reqSigs": 1,
"type": "scripthash",
"addresses": ["3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7"]
}
},
{
"value": "0.00015851",
"n": 1,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 b9c9bfe9e5b8656482d8c3fdaa029d119f8c5cf5 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914b9c9bfe9e5b8656482d8c3fdaa029d119f8c5cf588ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": ["1HwMhJTNhrPSv74oCe8g5otCeidEaHPm9p"]
},
"spentTxId": "3266dcc46b422d58b273ffd2acaf9dc2e72e26e3ec7fb82f25611341c7aea5d2",
"spentIndex": 0,
"spentTs": 1444374773
}],
"valueOut": 0.00016551,
"size": 224,
"valueIn": 0.00016775,
"fees": 0.00000224
}]
}
Also I can give all unspent outputs by address like this
https://blockexplorer.com/api/addrs/3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7/utxo?noCache=1[{
"address": "3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7",
"txid": "ba3141908a631be74dea503c6f0cdbb364e0a28df9d53f0a027b4cdeef673e9d",
"vout": 0,
"ts": 1444374903,
"scriptPubKey": "a914a287c1558aec11c6499dea08962cee0144be3eb587",
"amount": 0.000014,
"confirmationsFromCache": false
},
{
"address": "3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7",
"txid": "4c2da413bbeef2f1dd56a3d7e67af11d63eddd97906dd70afdbbcebdf9a589e7",
"vout": 0,
"ts": 1444374808,
"scriptPubKey": "a914a287c1558aec11c6499dea08962cee0144be3eb587",
"amount": 0.000011,
"confirmationsFromCache": false
},
{
"address": "3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7",
"txid": "3266dcc46b422d58b273ffd2acaf9dc2e72e26e3ec7fb82f25611341c7aea5d2",
"vout": 0,
"ts": 1444374773,
"scriptPubKey": "a914a287c1558aec11c6499dea08962cee0144be3eb587",
"amount": 0.00001,
"confirmationsFromCache": false
},
{
"address": "3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7",
"txid": "6ab8ac462b08b7883d82b69b2e8ae2e3008522ca50302f5c403dbfd16d9dc97b",
"vout": 0,
"ts": 1444374654,
"scriptPubKey": "a914a287c1558aec11c6499dea08962cee0144be3eb587",
"amount": 0.000007,
"confirmationsFromCache": false
}]
So in my vision if I want to spend
all coins from the address 3GWQ24JVWjVCT4uDKnvNJEbYJSwySQM4d7I should prepare rawTx with
ALL Unspent Outputs is it correct ? Any cases how can I simplify it?
createrawtransaction
"[
{\"txid\":\"ba3141908a631be74dea503c6f0cdbb364e0a28df9d53f0a027b4cdeef673e9d\",\"vout\":1},
{\"txid\":\"4c2da413bbeef2f1dd56a3d7e67af11d63eddd97906dd70afdbbcebdf9a589e7\",\"vout\":1},
{\"txid\":\"3266dcc46b422d58b273ffd2acaf9dc2e72e26e3ec7fb82f25611341c7aea5d2\",\"vout\":1},
{\"txid\":\"6ab8ac462b08b7883d82b69b2e8ae2e3008522ca50302f5c403dbfd16d9dc97b\",\"vout\":1},
]"
"{\"16rKfUnTnSiFdqRA3j69XNdfKwSBNxF5wX\":0.22302697}"
Thanks!