forked from bitcoin/bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to send and parse send-to-many transactions #1252
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dexX7
force-pushed
the
0.12.0-send-to-many
branch
3 times, most recently
from
March 25, 2022 11:40
1bdc620
to
776e7c3
Compare
dexX7
force-pushed
the
0.12.0-send-to-many
branch
from
March 27, 2022 16:12
757388a
to
f357a6a
Compare
This change adds the ability to construct, send and parse send-to-many transactions.
dexX7
force-pushed
the
0.12.0-send-to-many
branch
from
April 19, 2022 09:23
36f9b78
to
ea90386
Compare
dexX7
force-pushed
the
0.12.0-send-to-many
branch
from
April 20, 2022 08:03
4b21c89
to
70f55af
Compare
This was referenced May 31, 2022
Merged
counos
pushed a commit
to CounosH/counoslayer
that referenced
this pull request
Sep 27, 2023
…sactions Pull request description: This change adds the ability to construct and send send-to-many transactions. **What can you do?** - Send send-to-many transactions - Construct payloads for send-to-many transactions - Parse and retrieve data of send-to-many transactions - Balances are updated, when sending send-to-many transactions **What can't you do?** - This feature won't work on mainnet, until activated - Please note, this feature needs more testing **What's new?** A new transaction type 7 is introduced to transfer multiple tokens of one property id to multiple receivers. [Check out this link for a more detailed view.](https://gist.github.com/dexX7/1138fd1ea084a9db56798e9bce50d0ef) Two new RPCs were added to facilitate the new feature: - [omni_sendtomany](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#omni_sendtomany) to send send-to-many transactions via the user's wallet. - [omni_createpayload_sendtomany](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#omni_createpayload_sendtomany) to construct the plain payload. Note however, the rest of the transaction, in particular actually adding outputs for each receiver is still necessary. **What else is affected?** - [omni_gettransaction](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#omni_gettransaction) works! The new fields `receivers`, which provides a list for every receiver, and `totalamount` are most relevant for this transaction. See the examples below. - The change output of Omni transactions is no longer random, but added to the end of the transaction. - The transaction history window of the Qt client properly shows send to many transactions. - For more RPC examples, please visit [this link](https://gist.github.com/dexX7/ec0ab2b668db320b9f8534147add19bf) --- **Example 1:** You are a low level developer and want to manually craft transactions, then you can use the [raw transaction interface](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#raw-transactions) of Omni Core. To construct the payload for a send-to-many transaction: ``` omni_createpayload_sendtomany 31 '[{"output": 2, "amount": "10.5"}, {"output": 3, "amount": "0.5"}, {"output": 5, "amount": "15.0"}]' ``` ``` 000000070000001f0302000000003e95ba80030000000002faf080050000000059682f00 ``` --- **Example 2:** You have tokens in your wallet, which you want to transfer to two receivers, three units to one, five units to the other one: ``` omni_sendtomany "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C" 3 '[{"address": "mnM5bS3qQTxZSHkgpp2LDcKYL5thWtqCD6", "amount": "3"}, {"address": "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C", "amount": "5"}]' ``` ``` 55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa ``` --- **Example 3:** To then retrieve information about the transaction, you can use [omni_gettransaction](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#omni_gettransaction), which has the new fields `receivers` and `totalamount`. ``` omni_gettransaction 55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa ``` ``` { "txid": "55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa", "fee": "0.00002420", "sendingaddress": "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C", "ismine": true, "version": 0, "type_int": 7, "type": "Send To Many", "propertyid": 3, "divisible": false, "receivers": [ { "output": 1, "address": "mnM5bS3qQTxZSHkgpp2LDcKYL5thWtqCD6", "amount": "3" }, { "output": 2, "address": "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C", "amount": "5" } ], "totalamount": "8", "valid": false, "invalidreason": "Not enough funds in user address", "blockhash": "1ca23be7bee5dc915e76292e78aa1b42d75e4a3819d91871e69b24d292930687", "blocktime": 1648120618, "positioninblock": 2, "block": 112, "confirmations": 1 } ``` Please note, as mentioned above, the new transaction type doesn't affect consensus and balances, but can be used for testing. --- **Example 4:** Say you are a developer again and want to take a look at the above created transaction on a Bitcoin protocol level, then: ``` getrawtransaction 55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa 1 ``` ``` { "txid": "55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa", "hash": "d74b35b379f4796c918cc2475d4942f0a2e3caf9ae345488f56bac92384145ef", "version": 2, "size": 323, "vsize": 242, "weight": 965, "locktime": 0, "vin": [ { "txid": "2a89b07484fe8aa2b3038d32e2888b9b30de4553e23136e324502a0f049ed6b1", "vout": 3, "scriptSig": { "asm": "00149cae6190b0802e646e93b9006b7239b036002ca0", "hex": "1600149cae6190b0802e646e93b9006b7239b036002ca0" }, "txinwitness": [ "30440220651224e5c625d8163cb6e2971f58b191109b5dc02fb821694ada765ab424b23602206cd8787258b3538f78f157ac6d1d520a21d3e1febda9477d77120e171d0225a301", "02d0c8e0f374949dae9c0855d56af23b4d64c3c128fe336cd36a5270b2898a9964" ], "sequence": 4294967294 } ], "vout": [ { "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "OP_RETURN 6f6d6e69000000070000000302010000000000000003020000000000000005", "hex": "6a1f6f6d6e69000000070000000302010000000000000003020000000000000005", "type": "nulldata" } }, { "value": 0.00000546, "n": 1, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 4aead0759e716330b6c76ffaa4be6d27124efcef OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9144aead0759e716330b6c76ffaa4be6d27124efcef88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": [ "mnM5bS3qQTxZSHkgpp2LDcKYL5thWtqCD6" ] } }, { "value": 0.00000540, "n": 2, "scriptPubKey": { "asm": "OP_HASH160 b213aa3f6789fa2dca904d41d2bc4877d8437aa4 OP_EQUAL", "hex": "a914b213aa3f6789fa2dca904d41d2bc4877d8437aa487", "reqSigs": 1, "type": "scripthash", "addresses": [ "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C" ] } }, { "value": 4.99981210, "n": 3, "scriptPubKey": { "asm": "OP_HASH160 b213aa3f6789fa2dca904d41d2bc4877d8437aa4 OP_EQUAL", "hex": "a914b213aa3f6789fa2dca904d41d2bc4877d8437aa487", "reqSigs": 1, "type": "scripthash", "addresses": [ "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C" ] } } ], "hex": "02000000000101b1d69e040f2a5024e33631e25345de309b8b88e2328d03b3a28afe8474b0892a03000000171600149cae6190b0802e646e93b9006b7239b036002ca0feffffff040000000000000000216a1f6f6d6e6900000007000000030201000000000000000302000000000000000522020000000000001976a9144aead0759e716330b6c76ffaa4be6d27124efcef88ac1c0200000000000017a914b213aa3f6789fa2dca904d41d2bc4877d8437aa4879a1bcd1d0000000017a914b213aa3f6789fa2dca904d41d2bc4877d8437aa487024730440220651224e5c625d8163cb6e2971f58b191109b5dc02fb821694ada765ab424b23602206cd8787258b3538f78f157ac6d1d520a21d3e1febda9477d77120e171d0225a3012102d0c8e0f374949dae9c0855d56af23b4d64c3c128fe336cd36a5270b2898a996400000000", "blockhash": "1ca23be7bee5dc915e76292e78aa1b42d75e4a3819d91871e69b24d292930687", "confirmations": 1, "time": 1648120618, "blocktime": 1648120618 } ``` The above examples were created locally in regtest mode. # Conflicts: # src/counoscore/rpcpayload.cpp # src/counoscore/rpctx.cpp # src/counoscore/rpctxobject.cpp # src/counoscore/rules.cpp # src/counoscore/wallettxbuilder.cpp # src/omnicore/rpctxobject.h # src/rpc/client.cpp
counos
pushed a commit
to CounosH/counoslayer
that referenced
this pull request
Sep 27, 2023
…sactions Pull request description: This change adds the ability to construct and send send-to-many transactions. **What can you do?** - Send send-to-many transactions - Construct payloads for send-to-many transactions - Parse and retrieve data of send-to-many transactions - Balances are updated, when sending send-to-many transactions **What can't you do?** - This feature won't work on mainnet, until activated - Please note, this feature needs more testing **What's new?** A new transaction type 7 is introduced to transfer multiple tokens of one property id to multiple receivers. [Check out this link for a more detailed view.](https://gist.github.com/dexX7/1138fd1ea084a9db56798e9bce50d0ef) Two new RPCs were added to facilitate the new feature: - [omni_sendtomany](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#omni_sendtomany) to send send-to-many transactions via the user's wallet. - [omni_createpayload_sendtomany](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#omni_createpayload_sendtomany) to construct the plain payload. Note however, the rest of the transaction, in particular actually adding outputs for each receiver is still necessary. **What else is affected?** - [omni_gettransaction](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#omni_gettransaction) works! The new fields `receivers`, which provides a list for every receiver, and `totalamount` are most relevant for this transaction. See the examples below. - The change output of Omni transactions is no longer random, but added to the end of the transaction. - The transaction history window of the Qt client properly shows send to many transactions. - For more RPC examples, please visit [this link](https://gist.github.com/dexX7/ec0ab2b668db320b9f8534147add19bf) --- **Example 1:** You are a low level developer and want to manually craft transactions, then you can use the [raw transaction interface](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#raw-transactions) of Omni Core. To construct the payload for a send-to-many transaction: ``` omni_createpayload_sendtomany 31 '[{"output": 2, "amount": "10.5"}, {"output": 3, "amount": "0.5"}, {"output": 5, "amount": "15.0"}]' ``` ``` 000000070000001f0302000000003e95ba80030000000002faf080050000000059682f00 ``` --- **Example 2:** You have tokens in your wallet, which you want to transfer to two receivers, three units to one, five units to the other one: ``` omni_sendtomany "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C" 3 '[{"address": "mnM5bS3qQTxZSHkgpp2LDcKYL5thWtqCD6", "amount": "3"}, {"address": "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C", "amount": "5"}]' ``` ``` 55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa ``` --- **Example 3:** To then retrieve information about the transaction, you can use [omni_gettransaction](https://github.com/OmniLayer/omnicore/blob/develop/src/omnicore/doc/rpc-api.md#omni_gettransaction), which has the new fields `receivers` and `totalamount`. ``` omni_gettransaction 55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa ``` ``` { "txid": "55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa", "fee": "0.00002420", "sendingaddress": "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C", "ismine": true, "version": 0, "type_int": 7, "type": "Send To Many", "propertyid": 3, "divisible": false, "receivers": [ { "output": 1, "address": "mnM5bS3qQTxZSHkgpp2LDcKYL5thWtqCD6", "amount": "3" }, { "output": 2, "address": "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C", "amount": "5" } ], "totalamount": "8", "valid": false, "invalidreason": "Not enough funds in user address", "blockhash": "1ca23be7bee5dc915e76292e78aa1b42d75e4a3819d91871e69b24d292930687", "blocktime": 1648120618, "positioninblock": 2, "block": 112, "confirmations": 1 } ``` Please note, as mentioned above, the new transaction type doesn't affect consensus and balances, but can be used for testing. --- **Example 4:** Say you are a developer again and want to take a look at the above created transaction on a Bitcoin protocol level, then: ``` getrawtransaction 55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa 1 ``` ``` { "txid": "55d9f3eb56a5de5afef6b1d5dcdc2300d26d0aafcacbbfe387cba0983e0644fa", "hash": "d74b35b379f4796c918cc2475d4942f0a2e3caf9ae345488f56bac92384145ef", "version": 2, "size": 323, "vsize": 242, "weight": 965, "locktime": 0, "vin": [ { "txid": "2a89b07484fe8aa2b3038d32e2888b9b30de4553e23136e324502a0f049ed6b1", "vout": 3, "scriptSig": { "asm": "00149cae6190b0802e646e93b9006b7239b036002ca0", "hex": "1600149cae6190b0802e646e93b9006b7239b036002ca0" }, "txinwitness": [ "30440220651224e5c625d8163cb6e2971f58b191109b5dc02fb821694ada765ab424b23602206cd8787258b3538f78f157ac6d1d520a21d3e1febda9477d77120e171d0225a301", "02d0c8e0f374949dae9c0855d56af23b4d64c3c128fe336cd36a5270b2898a9964" ], "sequence": 4294967294 } ], "vout": [ { "value": 0.00000000, "n": 0, "scriptPubKey": { "asm": "OP_RETURN 6f6d6e69000000070000000302010000000000000003020000000000000005", "hex": "6a1f6f6d6e69000000070000000302010000000000000003020000000000000005", "type": "nulldata" } }, { "value": 0.00000546, "n": 1, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 4aead0759e716330b6c76ffaa4be6d27124efcef OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9144aead0759e716330b6c76ffaa4be6d27124efcef88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": [ "mnM5bS3qQTxZSHkgpp2LDcKYL5thWtqCD6" ] } }, { "value": 0.00000540, "n": 2, "scriptPubKey": { "asm": "OP_HASH160 b213aa3f6789fa2dca904d41d2bc4877d8437aa4 OP_EQUAL", "hex": "a914b213aa3f6789fa2dca904d41d2bc4877d8437aa487", "reqSigs": 1, "type": "scripthash", "addresses": [ "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C" ] } }, { "value": 4.99981210, "n": 3, "scriptPubKey": { "asm": "OP_HASH160 b213aa3f6789fa2dca904d41d2bc4877d8437aa4 OP_EQUAL", "hex": "a914b213aa3f6789fa2dca904d41d2bc4877d8437aa487", "reqSigs": 1, "type": "scripthash", "addresses": [ "2N9UopnCBgbC6wAjMaiqrBZjmgNFiZccY7C" ] } } ], "hex": "02000000000101b1d69e040f2a5024e33631e25345de309b8b88e2328d03b3a28afe8474b0892a03000000171600149cae6190b0802e646e93b9006b7239b036002ca0feffffff040000000000000000216a1f6f6d6e6900000007000000030201000000000000000302000000000000000522020000000000001976a9144aead0759e716330b6c76ffaa4be6d27124efcef88ac1c0200000000000017a914b213aa3f6789fa2dca904d41d2bc4877d8437aa4879a1bcd1d0000000017a914b213aa3f6789fa2dca904d41d2bc4877d8437aa487024730440220651224e5c625d8163cb6e2971f58b191109b5dc02fb821694ada765ab424b23602206cd8787258b3538f78f157ac6d1d520a21d3e1febda9477d77120e171d0225a3012102d0c8e0f374949dae9c0855d56af23b4d64c3c128fe336cd36a5270b2898a996400000000", "blockhash": "1ca23be7bee5dc915e76292e78aa1b42d75e4a3819d91871e69b24d292930687", "confirmations": 1, "time": 1648120618, "blocktime": 1648120618 } ``` The above examples were created locally in regtest mode.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change adds the ability to construct and send send-to-many transactions.
What can you do?
What's new?
A new transaction type 7 is introduced to transfer multiple tokens of one property id to multiple receivers. Check out this link for a more detailed view.
Two new RPCs were added to facilitate the new feature:
What else is affected?
receivers
, which provides a list for every receiver, andtotalamount
are most relevant for this transaction. See the examples below.For more RPC examples, please visit this link
Example 1:
You are a low level developer and want to manually craft transactions, then you can use the raw transaction interface of Omni Core. To construct the payload for a send-to-many transaction:
Example 2:
You have tokens in your wallet, which you want to transfer to two receivers, three units to one, five units to the other one:
Example 3:
To then retrieve information about the transaction, you can use omni_gettransaction, which has the new fields
receivers
andtotalamount
.Please note, as mentioned above, the new transaction type doesn't affect consensus and balances, but can be used for testing.
Example 4:
Say you are a developer again and want to take a look at the above created transaction on a Bitcoin protocol level, then:
The above examples were created locally in regtest mode.