-
Notifications
You must be signed in to change notification settings - Fork 19
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
feat: add witness signature for segwit tx #119
Conversation
submitter/relayer/utils.go
Outdated
return false, nil | ||
case *btcutil.AddressWitnessPubKeyHash: | ||
return true, nil | ||
case *btcutil.AddressWitnessScriptHash: |
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.
just curious what are ScriptHash
and PubKeyHash
?
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.
Basically, with the former, you pay the funds to a customized script, which allows customized locking/unlocking mechanisms. With the latter, you pay the funds to a public key. Anyone with the corresponding private key can unlock the script. For detailed explanation, See here.
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.
looks good!
submitter/relayer/utils.go
Outdated
|
||
func isSegWit(addr btcutil.Address) (bool, error) { | ||
switch addr.(type) { | ||
case *btcutil.AddressPubKeyHash: |
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.
Can't we use case lists here?
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, sure. Didn't realize we can use it. Thanks!
submitter/relayer/relayer.go
Outdated
|
||
// add signature/witness depending on the type of the previous address | ||
// if not segwit, add signature; otherwise, add witness | ||
ok, err := isSegWit(utxo.Addr) |
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, err := isSegWit(utxo.Addr) | |
segwit, err := isSegWit(utxo.Addr) |
This PR is to add witness signature for constructing a SegWit transaction. Basically, the submitter distinguishes the type of the utxo's address. If it's a SegWit type, then the transaction needs a signature script in the witness field to unlock the utxo, leaving the Signature field empty. For detailed explanation of scripting SegWit transactions, see here