I am having trouble coming to terms with the transaction construction flow outlined in the rosetta-specs - https://github.com/coinbase/rosetta-specifications#construction-api. I would like to create a simple example transaction where Bob sends Alice a satoshi. I would like to accomplish this as a series of post requests. Right now, I am trying to figure out how to structure a post request to the /construction/payloads endpoint.
My inspiration is the discussion here: Question about Construction API on blockchain like Bitcoin where Pat explains his “dry run” and “final run”. In the logs we see a series of requests and responses.
2020/10/30 14:46:34 REQUEST /construction/preprocess network_identifier:{"blockchain":"Bitcoin","network":"Testnet3"} intent:[{"operation_identifier":{"index":0},"type":"INPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"-1000000","currency":{"symbol":"tBTC","decimals":8}},"coin_change":{"coin_identifier":{"identifier":"443ff3d34eb31f99fc700dcd8141b1676a67c3376386609180af0c2fb4f41be0:0"},"coin_action":"coin_spent"}},{"operation_identifier":{"index":1},"type":"OUTPUT","status":"","account":{"address":"tb1qgfdw3dsw4ku5wemjnue2e5nc8zwlr7g0n0ajtr"},"amount":{"value":"570069","currency":{"symbol":"tBTC","decimals":8}}},{"operation_identifier":{"index":2},"type":"OUTPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"429789","currency":{"symbol":"tBTC","decimals":8}}}] metadata:null
2020/10/30 14:46:34 RESPONSE /construction/preprocess options:{"coins":[{"amount":{"currency":{"decimals":8,"symbol":"tBTC"},"value":"-1000000"},"coin_identifier":{"identifier":"443ff3d34eb31f99fc700dcd8141b1676a67c3376386609180af0c2fb4f41be0:0"}}],"estimated_size":142} required_public_keys:null
2020/10/30 14:46:34 REQUEST /construction/metadata network_identifier:{"blockchain":"Bitcoin","network":"Testnet3"} metadata:{"coins":[{"amount":{"currency":{"decimals":8,"symbol":"tBTC"},"value":"-1000000"},"coin_identifier":{"identifier":"443ff3d34eb31f99fc700dcd8141b1676a67c3376386609180af0c2fb4f41be0:0"}}],"estimated_size":142} public_keys:[]
2020/10/30 14:46:34 RESPONSE /construction/metadata metadata:{"script_pub_keys":[{"addresses":["tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"],"asm":"0 8b7c0d25aaab588a9133d041829a8a9b72715426","hex":"00148b7c0d25aaab588a9133d041829a8a9b72715426","reqSigs":1,"type":"witness_v0_keyhash"}]} suggested_fee:[{"value":"142","currency":{"symbol":"tBTC","decimals":8}}]
2020/10/30 14:46:34 REQUEST /construction/payloads network_identifier:{"blockchain":"Bitcoin","network":"Testnet3"} intent:[{"operation_identifier":{"index":0},"type":"INPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"-1000000","currency":{"symbol":"tBTC","decimals":8}},"coin_change":{"coin_identifier":{"identifier":"443ff3d34eb31f99fc700dcd8141b1676a67c3376386609180af0c2fb4f41be0:0"},"coin_action":"coin_spent"}},{"operation_identifier":{"index":1},"type":"OUTPUT","status":"","account":{"address":"tb1qgfdw3dsw4ku5wemjnue2e5nc8zwlr7g0n0ajtr"},"amount":{"value":"570069","currency":{"symbol":"tBTC","decimals":8}}},{"operation_identifier":{"index":2},"type":"OUTPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"429789","currency":{"symbol":"tBTC","decimals":8}}}] public_keys:[]
2020/10/30 14:46:34 RESPONSE /construction/payloads unsigned_transaction:"7b227472616e73616374696f6e223a2230313030303030303031653031626634623432663063616638303931363038363633333763333637366136376231343138316364306437306663393931666233346564336633336634343030303030303030303066666666666666663032643562323038303030303030303030303136303031343432356165386236306561646239343736373732396633326163643237383338396466316639306664643865303630303030303030303030313630303134386237633064323561616162353838613931333364303431383239613861396237323731353432363030303030303030222c227363726970745075624b657973223a5b7b2261736d223a22302038623763306432356161616235383861393133336430343138323961386139623732373135343236222c22686578223a223030313438623763306432356161616235383861393133336430343138323961386139623732373135343236222c2272657153696773223a312c2274797065223a227769746e6573735f76305f6b657968617368222c22616464726573736573223a5b22746231713364377136666432346476673479666e36707163397835326e6465387a347078356435647464225d7d5d2c22696e7075745f616d6f756e7473223a5b222d31303030303030225d2c22696e7075745f616464726573736573223a5b22746231713364377136666432346476673479666e36707163397835326e6465387a347078356435647464225d7d" payloads:[{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd","hex_bytes":"bdce218a9a09e943833437b8d856a53d2da09c8d27e69dbb60236d8d4706d42f","account_identifier":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"signature_type":"ecdsa"}]
2020/10/30 14:46:34 REQUEST /construction/parse network_identifier:{"blockchain":"Bitcoin","network":"Testnet3"} signed:false transaction:"7b227472616e73616374696f6e223a2230313030303030303031653031626634623432663063616638303931363038363633333763333637366136376231343138316364306437306663393931666233346564336633336634343030303030303030303066666666666666663032643562323038303030303030303030303136303031343432356165386236306561646239343736373732396633326163643237383338396466316639306664643865303630303030303030303030313630303134386237633064323561616162353838613931333364303431383239613861396237323731353432363030303030303030222c227363726970745075624b657973223a5b7b2261736d223a22302038623763306432356161616235383861393133336430343138323961386139623732373135343236222c22686578223a223030313438623763306432356161616235383861393133336430343138323961386139623732373135343236222c2272657153696773223a312c2274797065223a227769746e6573735f76305f6b657968617368222c22616464726573736573223a5b22746231713364377136666432346476673479666e36707163397835326e6465387a347078356435647464225d7d5d2c22696e7075745f616d6f756e7473223a5b222d31303030303030225d2c22696e7075745f616464726573736573223a5b22746231713364377136666432346476673479666e36707163397835326e6465387a347078356435647464225d7d"
2020/10/30 14:46:34 RESPONSE /construction/parse operations:[{"operation_identifier":{"index":0,"network_index":0},"type":"INPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"-1000000","currency":{"symbol":"tBTC","decimals":8}},"coin_change":{"coin_identifier":{"identifier":"443ff3d34eb31f99fc700dcd8141b1676a67c3376386609180af0c2fb4f41be0:0"},"coin_action":"coin_spent"}},{"operation_identifier":{"index":1,"network_index":0},"type":"OUTPUT","status":"","account":{"address":"tb1qgfdw3dsw4ku5wemjnue2e5nc8zwlr7g0n0ajtr"},"amount":{"value":"570069","currency":{"symbol":"tBTC","decimals":8}}},{"operation_identifier":{"index":2,"network_index":1},"type":"OUTPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"429789","currency":{"symbol":"tBTC","decimals":8}}}] signers:null metadata:null
2020/10/30 14:46:34 REQUEST /construction/combine network_identifier:{"blockchain":"Bitcoin","network":"Testnet3"} unsigned_transaction:"7b227472616e73616374696f6e223a2230313030303030303031653031626634623432663063616638303931363038363633333763333637366136376231343138316364306437306663393931666233346564336633336634343030303030303030303066666666666666663032643562323038303030303030303030303136303031343432356165386236306561646239343736373732396633326163643237383338396466316639306664643865303630303030303030303030313630303134386237633064323561616162353838613931333364303431383239613861396237323731353432363030303030303030222c227363726970745075624b657973223a5b7b2261736d223a22302038623763306432356161616235383861393133336430343138323961386139623732373135343236222c22686578223a223030313438623763306432356161616235383861393133336430343138323961386139623732373135343236222c2272657153696773223a312c2274797065223a227769746e6573735f76305f6b657968617368222c22616464726573736573223a5b22746231713364377136666432346476673479666e36707163397835326e6465387a347078356435647464225d7d5d2c22696e7075745f616d6f756e7473223a5b222d31303030303030225d2c22696e7075745f616464726573736573223a5b22746231713364377136666432346476673479666e36707163397835326e6465387a347078356435647464225d7d" signatures:[{"hex_bytes":"75e516943e2aa5165815810f6aefec8b27e2067729e4b75ac5127fd96a42bc0f0cb40a7193594cff2b9a92ea5d3081a05d62e50e1e0939308756a69d63fb028c","signing_payload":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd","hex_bytes":"bdce218a9a09e943833437b8d856a53d2da09c8d27e69dbb60236d8d4706d42f","account_identifier":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"signature_type":"ecdsa"},"public_key":{"hex_bytes":"031d5d7c8870bc00a49fa5f6204df4597b6b4b3e724926a40aacae0b58525f8dc0","curve_type":"secp256k1"},"signature_type":"ecdsa"}]
2020/10/30 14:46:34 RESPONSE /construction/combine network_transaction:"7b227472616e73616374696f6e223a22303130303030303030303031303165303162663462343266306361663830393136303836363333376333363736613637623134313831636430643730666339393166623334656433663333663434303030303030303030306666666666666666303264356232303830303030303030303030313630303134343235616538623630656164623934373637373239663332616364323738333839646631663930666464386530363030303030303030303031363030313438623763306432356161616235383861393133336430343138323961386139623732373135343236303234373330343430323230373565353136393433653261613531363538313538313066366165666563386232376532303637373239653462373561633531323766643936613432626330663032323030636234306137313933353934636666326239613932656135643330383161303564363265353065316530393339333038373536613639643633666230323863303132313033316435643763383837306263303061343966613566363230346466343539376236623462336537323439323661343061616361653062353835323566386463303030303030303030222c22696e7075745f616d6f756e7473223a5b222d31303030303030225d7d"
2020/10/30 14:46:34 REQUEST /construction/parse network_identifier:{"blockchain":"Bitcoin","network":"Testnet3"} signed:true transaction:"7b227472616e73616374696f6e223a22303130303030303030303031303165303162663462343266306361663830393136303836363333376333363736613637623134313831636430643730666339393166623334656433663333663434303030303030303030306666666666666666303264356232303830303030303030303030313630303134343235616538623630656164623934373637373239663332616364323738333839646631663930666464386530363030303030303030303031363030313438623763306432356161616235383861393133336430343138323961386139623732373135343236303234373330343430323230373565353136393433653261613531363538313538313066366165666563386232376532303637373239653462373561633531323766643936613432626330663032323030636234306137313933353934636666326239613932656135643330383161303564363265353065316530393339333038373536613639643633666230323863303132313033316435643763383837306263303061343966613566363230346466343539376236623462336537323439323661343061616361653062353835323566386463303030303030303030222c22696e7075745f616d6f756e7473223a5b222d31303030303030225d7d"
2020/10/30 14:46:34 RESPONSE /construction/parse operations:[{"operation_identifier":{"index":0,"network_index":0},"type":"INPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"-1000000","currency":{"symbol":"tBTC","decimals":8}},"coin_change":{"coin_identifier":{"identifier":"443ff3d34eb31f99fc700dcd8141b1676a67c3376386609180af0c2fb4f41be0:0"},"coin_action":"coin_spent"}},{"operation_identifier":{"index":1,"network_index":0},"type":"OUTPUT","status":"","account":{"address":"tb1qgfdw3dsw4ku5wemjnue2e5nc8zwlr7g0n0ajtr"},"amount":{"value":"570069","currency":{"symbol":"tBTC","decimals":8}}},{"operation_identifier":{"index":2,"network_index":1},"type":"OUTPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"429789","currency":{"symbol":"tBTC","decimals":8}}}] signers:[{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"}] metadata:null
2020/10/30 14:46:34 REQUEST /construction/hash network_identifier:{"blockchain":"Bitcoin","network":"Testnet3"} network_transaction:"7b227472616e73616374696f6e223a22303130303030303030303031303165303162663462343266306361663830393136303836363333376333363736613637623134313831636430643730666339393166623334656433663333663434303030303030303030306666666666666666303264356232303830303030303030303030313630303134343235616538623630656164623934373637373239663332616364323738333839646631663930666464386530363030303030303030303031363030313438623763306432356161616235383861393133336430343138323961386139623732373135343236303234373330343430323230373565353136393433653261613531363538313538313066366165666563386232376532303637373239653462373561633531323766643936613432626330663032323030636234306137313933353934636666326239613932656135643330383161303564363265353065316530393339333038373536613639643633666230323863303132313033316435643763383837306263303061343966613566363230346466343539376236623462336537323439323661343061616361653062353835323566386463303030303030303030222c22696e7075745f616d6f756e7473223a5b222d31303030303030225d7d"
2020/10/30 14:46:34 RESPONSE /construction/hash transaction_identifier:{"hash":"68229eefd85751d23015212a326a557fa74d98026ff2b775429012d65001d1b9"}
2020/10/30 14:46:34 QUEUE /construction/submit network_identifier:{"blockchain":"Bitcoin","network":"Testnet3"} intent:[{"operation_identifier":{"index":0},"type":"INPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"-1000000","currency":{"symbol":"tBTC","decimals":8}},"coin_change":{"coin_identifier":{"identifier":"443ff3d34eb31f99fc700dcd8141b1676a67c3376386609180af0c2fb4f41be0:0"},"coin_action":"coin_spent"}},{"operation_identifier":{"index":1},"type":"OUTPUT","status":"","account":{"address":"tb1qgfdw3dsw4ku5wemjnue2e5nc8zwlr7g0n0ajtr"},"amount":{"value":"570069","currency":{"symbol":"tBTC","decimals":8}}},{"operation_identifier":{"index":2},"type":"OUTPUT","status":"","account":{"address":"tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"},"amount":{"value":"429789","currency":{"symbol":"tBTC","decimals":8}}}] transaction_identifier:{"hash":"68229eefd85751d23015212a326a557fa74d98026ff2b775429012d65001d1b9"} network_transaction:"7b227472616e73616374696f6e223a22303130303030303030303031303165303162663462343266306361663830393136303836363333376333363736613637623134313831636430643730666339393166623334656433663333663434303030303030303030306666666666666666303264356232303830303030303030303030313630303134343235616538623630656164623934373637373239663332616364323738333839646631663930666464386530363030303030303030303031363030313438623763306432356161616235383861393133336430343138323961386139623732373135343236303234373330343430323230373565353136393433653261613531363538313538313066366165666563386232376532303637373239653462373561633531323766643936613432626330663032323030636234306137313933353934636666326239613932656135643330383161303564363265353065316530393339333038373536613639643633666230323863303132313033316435643763383837306263303061343966613566363230346466343539376236623462336537323439323661343061616361653062353835323566386463303030303030303030222c22696e7075745f616d6f756e7473223a5b222d31303030303030225d7d"
I was hoping that I could slightly modify line 5 to make a successful post request, like so:
{
"network_identifier": {
"blockchain": "Bitcoin",
"network": "Testnet3"
},
"operations": [
{
"operation_identifier": {
"index": 0
},
"type": "INPUT",
"status": "",
"account": {
"address": "tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"
},
"amount": {
"value": "-1000000",
"currency": {
"symbol": "tBTC",
"decimals": 8
}
},
"coin_change": {
"coin_identifier": {
"identifier": "443ff3d34eb31f99fc700dcd8141b1676a67c3376386609180af0c2fb4f41be0:0"
},
"coin_action": "coin_spent"
}
},
{
"operation_identifier": {
"index": 1
},
"type": "OUTPUT",
"status": "",
"account": {
"address": "tb1qgfdw3dsw4ku5wemjnue2e5nc8zwlr7g0n0ajtr"
},
"amount": {
"value": "570069",
"currency": {
"symbol": "tBTC",
"decimals": 8
}
}
},
{
"operation_identifier": {
"index": 2
},
"type": "OUTPUT",
"status": "",
"account": {
"address": "tb1q3d7q6fd24dvg4yfn6pqc9x52nde8z4px5d5dtd"
},
"amount": {
"value": "429789",
"currency": {
"symbol": "tBTC",
"decimals": 8
}
}
}
]
}
Surely, I am missing some piece of information, but am I going in the right direction with all this? Looking forward to hearing from everyone. Thanks for the input.