Skip to content
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

Wallet: create batch transactions with any combination of covenants #686

Merged
merged 10 commits into from
Aug 3, 2022

Conversation

pinheadmz
Copy link
Member

@pinheadmz pinheadmz commented Feb 1, 2022

Creates batching functions in the wallet and exposes two new RPC calls: sendbatch and createbatch. The argument is an array of "actions". Actions are an array that starts with a string indicating the action type (usually a covenant but could also be meta-covenant type like CANCEL) followed by the arguments expected by the corresponding make___() function.

Examples:

# open multiple names in one TX
hsw-rpc sendbatch [['OPEN', 'menace'], ['OPEN', 'to'], ['OPEN', 'the'], ['OPEN', 'network']]

# send bids (with lockups) for multiple names in one TX:
hsw-rpc sendbatch [['BID', 'menace', 100, 100], ['BID', 'to', 1, 2], ['BID', 'the', 30, 40], ['BID', 'network', 100, 100]]

# mix and match!!!
hsw-rpc sendbatch [['REDEEM', 'menace'], ['REDEEM', 'to'], ['UPDATE', 'the', {"records":[]}], ['UPDATE', 'network', {"records":[]}]]

# even works with NONE!
hsw-rpc sendbatch '[["OPEN", "heynicetomeetyou"], ["NONE", "rs1qruzqgxl4qvs4fj3v8k6zjxwem6236pam0tjv7w", 1.123456]]'

TODO:

  • consider address reuse: all outputs of a batch will have the same receive address because that index is not incremented until the TX is done and added back to the wallet
  • test rpc

@coveralls
Copy link

coveralls commented Feb 1, 2022

Coverage Status

Coverage increased (+0.2%) to 67.176% when pulling 89e5a06 on pinheadmz:multiaction into 999145a on handshake-org:master.

test/wallet-auction-test.js Outdated Show resolved Hide resolved
@DIPMR
Copy link

DIPMR commented Jul 2, 2022

< $ hsw-rpc sendbatch '[["REDEEM", "name1"],["REDEEM" ,"name1"],["REDEEM", "name1"],["REDEEM","name1"]]' > throws error "no reveals to redeem" while < $ hsw-rpc sendredeem > works fine and redeems all the lost bids.

@pinheadmz pinheadmz force-pushed the multiaction branch 2 times, most recently from 0e4482e to 5e33184 Compare July 28, 2022 19:00
@pinheadmz
Copy link
Member Author

< $ hsw-rpc sendbatch '[["REDEEM", "name1"],["REDEEM" ,"name1"],["REDEEM", "name1"],["REDEEM","name1"]]' > throws error "no reveals to redeem" while < $ hsw-rpc sendredeem > works fine and redeems all the lost bids.

@DIPMR you shouldn't need to call REDEEM multiple times with the same name. As you discovered, a single sendredeem <name> will redeem all losing bids for a name.

You could try hsw-rpc sendbatch '[["REDEEM", "name1"]]' and that should work

if you were trying to redeem multiple different names and got this error, could you let me know?

@pinheadmz
Copy link
Member Author

@DIPMR I was able to redeem in batches using this series of commands on regtest:

  hsw-rpc sendbatch '[["OPEN", "name1"],["OPEN","name2"],["OPEN","name3"]]'
  gen 7 # generate blocks
  hsw-rpc sendbatch '[["BID", "name1", 1, 1],["BID","name2", 1, 1],["BID","name3", 1, 1]]'
  hsw-rpc sendbatch '[["BID", "name1", 2, 2],["BID","name2", 2, 2],["BID","name3", 2, 2]]'
  hsw-rpc sendbatch '[["BID", "name1", 3, 3],["BID","name2", 3, 3],["BID","name3", 3, 3]]'
  gen 7
  hsw-rpc sendbatch '[["REVEAL", "name1"],["REVEAL","name2"],["REVEAL","name3"]]'
  gen 7
  hsw-rpc sendbatch '[["REDEEM", "name1"],["REDEEM","name2"],["REDEEM","name3"]]'
  hsw-rpc sendbatch '[["UPDATE", "name1", {"records":[]}],["UPDATE","name2", {"records":[]}],["UPDATE","name3", {"records":[]}]]'

@HDardenne HDardenne self-requested a review July 28, 2022 19:58
Copy link
Member

@HDardenne HDardenne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me !

@pinheadmz pinheadmz merged commit a747dc8 into handshake-org:master Aug 3, 2022
pinheadmz added a commit to rithvikvibhu/hsd that referenced this pull request Dec 20, 2022
@nodech nodech added wallet part of the codebase breaking-minor Backwards compatible - Release version labels Jan 9, 2023
@nodech nodech mentioned this pull request Jan 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-minor Backwards compatible - Release version wallet part of the codebase
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants