Skip to content
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

btcutil/psbt: export helper functions, fix/add encoding of unknown fields #1942

Merged
merged 6 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions btcutil/psbt/bip32.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Bip32Derivation struct {
// PubKey is the raw pubkey serialized in compressed format.
PubKey []byte

// MasterKeyFingerprint is the finger print of the master pubkey.
// MasterKeyFingerprint is the fingerprint of the master pubkey.
MasterKeyFingerprint uint32

// Bip32Path is the BIP 32 path with child index as a distinct integer.
Expand All @@ -36,10 +36,10 @@ func (s Bip32Sorter) Less(i, j int) bool {
return bytes.Compare(s[i].PubKey, s[j].PubKey) < 0
}

// readBip32Derivation deserializes a byte slice containing chunks of 4 byte
// ReadBip32Derivation deserializes a byte slice containing chunks of 4 byte
// little endian encodings of uint32 values, the first of which is the
// masterkeyfingerprint and the remainder of which are the derivation path.
func readBip32Derivation(path []byte) (uint32, []uint32, error) {
func ReadBip32Derivation(path []byte) (uint32, []uint32, error) {
// BIP-0174 defines the derivation path being encoded as
// "<32-bit uint> <32-bit uint>*"
// with the asterisk meaning 0 to n times. Which in turn means that an
Expand Down
5 changes: 3 additions & 2 deletions btcutil/psbt/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ func Extract(p *Packet) (*wire.MsgTx, error) {
return nil, err
}

// Now that we know how may inputs we'll need, we'll
// Now that we know how many inputs we'll need, we'll
// construct a packing slice, then read out each input
// (with a varint prefix) from the witnessReader.
tin.Witness = make(wire.TxWitness, witCount)
for j := uint64(0); j < witCount; j++ {
wit, err := wire.ReadVarBytes(
witnessReader, 0, txscript.MaxScriptSize, "witness",
witnessReader, 0,
txscript.MaxScriptSize, "witness",
)
if err != nil {
return nil, err
Expand Down
5 changes: 4 additions & 1 deletion btcutil/psbt/finalizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ package psbt
import (
"bytes"
"fmt"

"github.com/btcsuite/btcd/txscript"
"github.com/btcsuite/btcd/wire"
)
Expand Down Expand Up @@ -462,7 +463,9 @@ func finalizeWitnessInput(p *Packet, inIndex int) error {
return ErrNotFinalizable
}

serializedWitness, err = writePKHWitness(sigs[0], pubKeys[0])
serializedWitness, err = writePKHWitness(
sigs[0], pubKeys[0],
)
if err != nil {
return err
}
Expand Down
Loading