-
Notifications
You must be signed in to change notification settings - Fork 14
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
examples: Add salvage_webwallet.py. #194
base: master
Are you sure you want to change the base?
Conversation
4f6bd30
to
4b9f8e5
Compare
decred/examples/drain_xpriv.py
Outdated
try: | ||
addr = addrlib.deriveChildAddress(key, idx, net) | ||
except Exception: | ||
# Very small chance of a bad address. | ||
pass | ||
try: | ||
res = node.searchRawTransactions(addr, verbose=True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider a pattern where you check all the addresses at once using existsAddresses
, and then only checking searchRawTransactions
for those that pass existsAddresses
. With existsAddresses
, you can check all GAP_LIMIT
addresses at once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hadn't thought of that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to leave like it is for now, if that's ok.
decred/examples/drain_xpriv.py
Outdated
GAP_LIMIT = 20 | ||
|
||
|
||
def cfg(isTestnet): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to fix in a future pr? I also need a check for txindex being enables for this...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just addrindex? not really sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking both, I'm sure there's a way to write it so that we can do everything with one method though.
decred/examples/drain_xpriv.py
Outdated
return cfg | ||
|
||
|
||
def decodeExtendedKey(netParams, key): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely encouraged to modify package code to help with examples. What's good is the code but if not to help with stuff like this? Consider https://github.com/JoeGruffins/tinydecred/compare/dumpxpriv...buck54321:jg?expand=1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, but I really wanted to make this script accessible with the release. I will change this in a later pr...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When testing on testnet I got the following result:
Is this mainnet or testnet?
testnet
Enter xpriv: tprvZbj7CwXadom3SKPoKo5hctmjqt2wn8uA4YKDwHnyoFEYwQBGD28VPidrSLZbik5zzkCucnZnWmrZNZB1xDcf4XTyvkPxEmDmJmDB9vueVkj
Found 1 outputs totalling 0.02858322 tdcr.
Input address to send funds: Tsa8ZBbLk2rRjrEQWoGaBXKBSztxdbs91WB
Got the raw hex: 0100000001c3581c5f38e852a05d705a5281d616454f0b43dfa2b03f8983e4a8b8abf37eff4300000000ffffffff0110992b000000000000001976a91463f040a8f1bd956ae62f1f4daeee6526b70090e988ac000000000000000001529d2b000000000000000000000000006b483045022100d0c927ebedb363eaa16956bcdf2220a1f942f78d96e2e4963818bd2ebf79263b02201719949b7a2436862f710d247a70ff7694f5bbadaa69c739abdc3bd6b148b7010121029f2b09b91e05ce793f782242f559b4b7317e05567ee3c2c35b83196678997cb5
txid: cb298ccd53c044e6a20dfcc6e50311a27379cd022b4b1cecbfbd8abe379e0e64
serType: 0
version: 1
txIn 0:
previousOutPoint:
txid: ff7ef3abb8a8e483893fb0a2df430b4f4516d681525a705da052e8385f1c58c3
idx: 67
tree: 0
sequence: 4294967295
valueIn: 2858322
blockHeight: 0
blockIndex: 0
signatureScript: 483045022100d0c927ebedb363eaa16956bcdf2220a1f942f78d96e2e4963818bd2ebf79263b02201719949b7a2436862f710d247a70ff7694f5bbadaa69c739abdc3bd6b148b7010121029f2b09b91e05ce793f782242f559b4b7317e05567ee3c2c35b83196678997cb5
txOut 0:
value: 2857232
version: 0
pkScript: 76a91463f040a8f1bd956ae62f1f4daeee6526b70090e988ac
lockTime: 0
expiry: 0
Really send funds to Tsa8ZBbLk2rRjrEQWoGaBXKBSztxdbs91WB?
yes
Traceback (most recent call last):
File "./drain_xpriv.py", line 255, in <module>
main()
File "./drain_xpriv.py", line 249, in main
txid = node.sendRawTransaction(signedTx)
File "/home/vctt/.local/lib/python3.7/site-packages/decred/dcr/rpc.py", line 1109, in sendRawTransaction
txid = self.call("sendrawtransaction", msgTx.txHex(), allowHighFees)
File "/home/vctt/.local/lib/python3.7/site-packages/decred/dcr/rpc.py", line 176, in call
raise DecredError(f"{method} error: {resp.error}")
decred.DecredError: sendrawtransaction error: {'code': -1, 'message': 'rejected transaction cb298ccd53c044e6a20dfcc6e50311a27379cd022b4b1cecbfbd8abe379e0e64: transaction cb298ccd53c044e6a20dfcc6e50311a27379cd022b4b1cecbfbd8abe379e0e64 has insufficient priority (3.009644929411765e+07 <= 5.76e+07)'}
This script is meant to enable someone who has an xpriv from an old copay wallet to move their funds to a new wallet.
28cab0a
to
fdc2c1f
Compare
We have verification that this script was able to salvage someone's funds on mainnet: https://dcrdata.decred.org/tx/1fade79b970e330205f08703f13734b0fcb78ae21b8714e36df1ae1237d4e0e3 I am going to push back on any more optimization. This is working and doesn't need to be super optimal memory-wise. It's a one timer per person thing. Would like to make it more user friendly if possible. And of course if there are any bugs they should be fixed... |
This might be a useful tool people trying to salvage funds from a "web wallet".