Open Shadowfiend opened 4 years ago
Low-key excited for this - I've got a hacked-together local Bitcoin regtest and ElectrumX setup here, and it's currently only blocked by the dApp redemption script requiring a specific network prefix in the address.
Update here: all we need to do is Script.fromAddress
, which will either work or not (returning null
or not). keep-network/tbtc.js#8 will implement this for tbtc.js, then we'll adjust the validation here briefly.
EDIT to add: current contracts don't support this. When we bump to the latest tbtc contracts, they do support arbitrary redeemer scripts. We'll need to harmonize what we currently do with that anyway (these scripts require length prefixes, which the current code doesn't ship to the contract) and see what the best way is to support it with bcoin. The rest of the issue remains for now, as it will probably still inform what we end up doing.
Right now, we only accept bech32 p2wpkh addresses in the redemption flow. We should be able to do more than that, with a little bit of massaging of our
bcoin
invocations.Here's what we do right now:
https://github.com/keep-network/tbtc-dapp/blob/5b0de38078dcad023046d897c87c4fc175dbc3f4/client/src/redemption.js#L54-L55
For a p2pkh address, we can do
script.getPubkeyhash()
. For a p2sh/p2wsh address, it looks like things might be slightly more complicated… From some mucking around in node-land:99% sure we just want
script.code[1].data
, based on the fact that this looks like the structure that we look for in p2wpkh:However, in p2wpkh that's behind an OP_HASH160 opcode and in p2sh it seems to be behind no opcode at all sooo… Yeah, not sure. Probably easiest to just try the thing, tbh 🤷♂