trezor / trezor-firmware

:lock: Trezor Firmware Monorepo
https://trezor.io
Other
1.34k stars 652 forks source link

decred: Support spending from treasury generation outputs. #2096

Open JoeGruffins opened 2 years ago

JoeGruffins commented 2 years ago

Recently a few new opcodes were added to decred that allow the decentralized treasury to work as intended. The new opcodes are these https://github.com/decred/dcrd/blob/bcc5023fa94d2e0895682012081fbe3cef3d6b51/txscript/opcode.go#L246-L248

They allow funds to be spent from the treasury to user addresses. The OP_TGEN opcode in particular is part of a script that needs to be signed by recipients of a treasury spend. For these users to accept funds with their trezor, they will need to be able to sign and spend treasury generation scripts. It would be great if we could add these to signing verification.

Here are the changes that I believe need to be made, minus tests: https://github.com/JoeGruffins/trezor-firmware/commit/106771aa853d55366682e0a94f6ec1f57518a184

Because treasury gen outputs are grouped into the same stake tree as ticket outputs, I think just adding another enum to DecredStakingSpendType is fine.

Here you can see on mainnet what treasury adds and spends look like https://explorer.dcrdata.org/tx/c20c6ead8a45a03020b3083691ee79bf6abd74f4a6054cbf7a6d20753443e252

Will wait for feedback before progressing.

sime commented 2 years ago

Hi @JoeGruffins

Thanks for coming up with the initial code, but we're not prioritising this code change (i.e. potential PR) at the moment.