-
Notifications
You must be signed in to change notification settings - Fork 97
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
bch: switch to testnet4 and use custom address stringer #1606
Conversation
// Expiration returns the expiration time of the contract, which is the earliest | ||
// time that a refund can be issued for an un-redeemed contract. Part of the | ||
// asset.AuditInfo interface. |
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.
At one point there was an asset.AuditInfo
interface, but it it became a concrete type at one point and these remained.
if err != nil { | ||
return nil, nil, err | ||
} | ||
privKey, err := btc.node.privKeyForAddress(addrStr) |
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.
Not sure, but perhaps bitcoincashd
(Bitcoin Cash Node) was able to pull out the pubkey from the bitcoin/legacy addresses and locate the private key. The chain params were the clone params with the correct bch address ID values, but this wasn't making Cash Addresses.
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.
Yeah, that's what it was doing.
$ ./beta getaddressinfo mgDzcoxdBrhu435knkdUEP5UGVYGKUJJgN
{
"address": "bchreg:qqru9lns98ugq85h4cl3p8srf4y9w8cyt5eux55xmn",
"scriptPubKey": "76a91407c2fe7029f8801e97ae3f109e034d48571f045d88ac",
"ismine": true,
"iswatchonly": false,
"isscript": false,
"pubkey": "0310892969dde0c7f6e177ce0f1a8ba807fbbbbc05135e9c47479f0aa1fa2555a5",
...
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.
Interesting.
|
Ah, dang. Hopefully we did things similarly. |
We're close. I can minimize conflicts because having this fix separate makes sense IMO, but some points:
|
Your way is better. I'll adapt. |
Shall I merge this then? |
29103e5
to
6b3c30c
Compare
Or just discard the stringer commit? Whatever |
Any leads on getting some testnet4 BCH? |
site: add bch explorer links
The exchange wallets had an address decoder function for converting a string to a btcutil.Address, which is required for assets like BCH with special address formats. However, it is incorrect to then use the btcutil.Address String method go get a human readable address. This adds a complementary helper function for converting from a btcutil.Address to a correct string. Normally this is simply using the Address as a Stringer, but for BCH it is the new EncodeCashAddress function, which powers the existing RecodeCashAddress. This updates the btc baseWallet methods to use the new stringAddr to achieve the reverse of decodeAddr. This ensures that the string address stored in the fundingCoins is correct for the asset. This also ensures the recipient address in AuditContract is correct. I believe the main issue resolved by this is providing the correct address to the node.privKeyForAddress method when signing. This also provides the correct string to the getaddressinfo RPC. It is not clear if bitcoincashd was previously ok with the incorrect address strings when handling RPCs. This also removes the unused (*auditInfo).Recipient method, and fixes the documentation for the other methods since there is no longer an asset.AuditInfo *interface*, just a struct.
Pulled out of a larger Electrum branch.
This does:
baseWallet
to resolve what appears to be incorrect conversion ofbtcutil.Address
types to strings in places. See commit message below.