Skip to content

Commit

Permalink
Merge tag 'btcutil/psbt/v1.1.2' into main
Browse files Browse the repository at this point in the history
btcutil/psbt/v1.1.2
  • Loading branch information
wakiyamap committed May 3, 2022
2 parents 3ceccda + b34e376 commit 9824cf7
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 31 deletions.
16 changes: 8 additions & 8 deletions blockchain/thresholdstate.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func thresholdStateTransition(state ThresholdState, prevNode *blockNode,
// speed deployments can only transition to failed
// after a confirmation window.
if !checker.IsSpeedy() && checker.HasEnded(prevNode) {
log.Infof("Moving from state=%v, to state=%v", state,
log.Debugf("Moving from state=%v, to state=%v", state,
ThresholdFailed)

state = ThresholdFailed
Expand All @@ -182,7 +182,7 @@ func thresholdStateTransition(state ThresholdState, prevNode *blockNode,
// once its start time has been reached (and it hasn't
// already expired per the above).
if checker.HasStarted(prevNode) {
log.Infof("Moving from state=%v, to state=%v", state,
log.Debugf("Moving from state=%v, to state=%v", state,
ThresholdStarted)

state = ThresholdStarted
Expand All @@ -193,7 +193,7 @@ func thresholdStateTransition(state ThresholdState, prevNode *blockNode,
// expires before it is accepted and locked in, but
// only if this deployment isn't speedy.
if !checker.IsSpeedy() && checker.HasEnded(prevNode) {
log.Infof("Moving from state=%v, to state=%v", state,
log.Debugf("Moving from state=%v, to state=%v", state,
ThresholdFailed)

state = ThresholdFailed
Expand Down Expand Up @@ -223,7 +223,7 @@ func thresholdStateTransition(state ThresholdState, prevNode *blockNode,
// period that voted for the rule change meets the
// activation threshold.
case count >= checker.RuleChangeActivationThreshold():
log.Infof("Moving from state=%v, to state=%v", state,
log.Debugf("Moving from state=%v, to state=%v", state,
ThresholdLockedIn)

state = ThresholdLockedIn
Expand All @@ -232,13 +232,13 @@ func thresholdStateTransition(state ThresholdState, prevNode *blockNode,
// threshold above, and the deployment has expired, then
// we transition to failed.
case checker.IsSpeedy() && checker.HasEnded(prevNode):
log.Infof("Moving from state=%v, to state=%v", state,
log.Debugf("Moving from state=%v, to state=%v", state,
ThresholdFailed)

state = ThresholdFailed

default:
log.Infof("Still at state=%v, threshold=%v", state,
log.Tracef("Still at state=%v, threshold=%v", state,
float64(count)/float64(checker.RuleChangeActivationThreshold()))
}

Expand All @@ -251,12 +251,12 @@ func thresholdStateTransition(state ThresholdState, prevNode *blockNode,
// If we aren't eligible to active yet, then we'll just
// stay in the locked in position.
if !checker.EligibleToActivate(prevNode) {
log.Infof("Moving from state=%v, to state=%v", state,
log.Debugf("Moving from state=%v, to state=%v", state,
ThresholdLockedIn)

state = ThresholdLockedIn
} else {
log.Infof("Moving from state=%v, to state=%v", state,
log.Debugf("Moving from state=%v, to state=%v", state,
ThresholdActive)

// The new rule becomes active when its
Expand Down
2 changes: 1 addition & 1 deletion btcec/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/davecgh/go-spew v1.1.1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1
github.com/monasuite/monad/chaincfg/chainhash v1.0.1
github.com/monasuite/monad/chaincfg/chainhash v1.0.2
)

require github.com/decred/dcrd/crypto/blake256 v1.0.0 // indirect
4 changes: 2 additions & 2 deletions btcec/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/monasuite/monad/chaincfg/chainhash v1.0.1 h1:vP/pZogC/GREzHJKpFDakcGD+4r4/qZLH3a/U7VA3q4=
github.com/monasuite/monad/chaincfg/chainhash v1.0.1/go.mod h1:EeTDpYGmOWLFkKhF+EzOI3ESfTDpu44E10mysOrpVgI=
github.com/monasuite/monad/chaincfg/chainhash v1.0.2 h1:JcHggux+DO3oAN79xe57edCXHNwLc5lkNizUiAtDC9E=
github.com/monasuite/monad/chaincfg/chainhash v1.0.2/go.mod h1:EeTDpYGmOWLFkKhF+EzOI3ESfTDpu44E10mysOrpVgI=
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require (
github.com/decred/dcrd/lru v1.0.0
github.com/jessevdk/go-flags v1.4.0
github.com/jrick/logrotate v1.0.0
github.com/monasuite/monad/btcec/v2 v2.1.2
github.com/monasuite/monad/chaincfg/chainhash v1.0.1
github.com/monasuite/monad/btcec/v2 v2.1.3
github.com/monasuite/monad/chaincfg/chainhash v1.0.2
github.com/monasuite/monad/monautil v1.1.0
github.com/shopspring/decimal v1.3.1
github.com/stretchr/testify v1.7.0
Expand All @@ -33,10 +33,6 @@ require (

replace github.com/monasuite/monad/monautil => ./monautil

replace github.com/monasuite/monad/chaincfg/chainhash => ./chaincfg/chainhash

replace github.com/monasuite/monad/btcec/v2 => ./btcec

// The retract statements below fixes an accidental push of the tags of a btcd
// fork.
retract (
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+
github.com/monasuite/monad v0.21.0-beta/go.mod h1:3Xp+i5gmkjEl2pUvj558OUuLsMqjB5S3663Nr0yRa58=
github.com/monasuite/monad v0.22.0-beta/go.mod h1:ZHQyEBbhHEPYyhDn9VxJoWW2GJ5lZgOUtIw4xMVOAVE=
github.com/monasuite/monad v0.22.3-beta.0.20220423152854-630e468daa19/go.mod h1:KH0yZrcZYBhL6uKlHPDyXv7P6hXMwstSuJQcZ5iVtEM=
github.com/monasuite/monad/btcec/v2 v2.1.3 h1:TfCTFxEHLr+jSfzvFiux7CONiGZwPlCkg+P7TWZOdmc=
github.com/monasuite/monad/btcec/v2 v2.1.3/go.mod h1:XGc5eY42XX3WLnU7/Ntu0GjRx7L/bmhCjhAF4xKcVy8=
github.com/monasuite/monad/chaincfg/chainhash v1.0.1/go.mod h1:EeTDpYGmOWLFkKhF+EzOI3ESfTDpu44E10mysOrpVgI=
github.com/monasuite/monad/chaincfg/chainhash v1.0.2 h1:JcHggux+DO3oAN79xe57edCXHNwLc5lkNizUiAtDC9E=
github.com/monasuite/monad/chaincfg/chainhash v1.0.2/go.mod h1:EeTDpYGmOWLFkKhF+EzOI3ESfTDpu44E10mysOrpVgI=
github.com/monasuite/monautil v0.0.0-20190606162653-90b266792864/go.mod h1:kIVSL9QpyEYOh60Z7DIAAIhzOd9pHpRbMA3rOqVXOwc=
github.com/monasuite/monautil v1.1.0/go.mod h1:b5tmGuaSp+AMFptTgNUuYWwct+WTaS+lSh2yUkQQQvw=
github.com/monasuite/monautil v1.1.1/go.mod h1:N1fiuHcY7yZtugY+8dUeJyFjcBRJvk1z/P/KpGpkHU4=
Expand Down
8 changes: 2 additions & 6 deletions monautil/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@ require (
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1
github.com/kkdai/bstream v1.0.0
github.com/monasuite/monad v0.22.3-beta.0.20220423152854-630e468daa19
github.com/monasuite/monad/btcec/v2 v2.1.2
github.com/monasuite/monad/chaincfg/chainhash v1.0.1
github.com/monasuite/monad/btcec/v2 v2.1.3
github.com/monasuite/monad/chaincfg/chainhash v1.0.2
github.com/shopspring/decimal v1.3.1
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
)

replace github.com/monasuite/monad => ../

replace github.com/monasuite/monad/chaincfg/chainhash => ../chaincfg/chainhash

replace github.com/monasuite/monad/btcec/v2 => ../btcec
6 changes: 6 additions & 0 deletions monautil/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/kkdai/bstream v1.0.0 h1:Se5gHwgp2VT2uHfDrkbbgbgEvV9cimLELwrPJctSjg8=
github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA=
github.com/monasuite/monad/btcec/v2 v2.1.0/go.mod h1:kV95/Yy3mUS6A45yvNynYHjIXM+4k8GsL61EyxaL6H0=
github.com/monasuite/monad/btcec/v2 v2.1.3 h1:TfCTFxEHLr+jSfzvFiux7CONiGZwPlCkg+P7TWZOdmc=
github.com/monasuite/monad/btcec/v2 v2.1.3/go.mod h1:XGc5eY42XX3WLnU7/Ntu0GjRx7L/bmhCjhAF4xKcVy8=
github.com/monasuite/monad/chaincfg/chainhash v1.0.1/go.mod h1:EeTDpYGmOWLFkKhF+EzOI3ESfTDpu44E10mysOrpVgI=
github.com/monasuite/monad/chaincfg/chainhash v1.0.2 h1:JcHggux+DO3oAN79xe57edCXHNwLc5lkNizUiAtDC9E=
github.com/monasuite/monad/chaincfg/chainhash v1.0.2/go.mod h1:EeTDpYGmOWLFkKhF+EzOI3ESfTDpu44E10mysOrpVgI=
github.com/monasuite/monad/monautil v1.1.0/go.mod h1:fiV9i+Btjd+5kCaf3XzZ2XbCPzVBDaDLslRALYIV7PM=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
Expand Down
7 changes: 5 additions & 2 deletions monautil/psbt/bip32.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ func (s Bip32Sorter) Less(i, j int) bool {
// 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) {

if len(path)%4 != 0 || len(path)/4-1 < 1 {
// 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
// empty path is valid, only the key fingerprint is mandatory.
if len(path)%4 != 0 {
return 0, nil, ErrInvalidPsbtFormat
}

Expand Down
8 changes: 2 additions & 6 deletions monautil/psbt/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ go 1.13
require (
github.com/davecgh/go-spew v1.1.1
github.com/monasuite/monad v0.22.3-beta.0.20220423152854-630e468daa19
github.com/monasuite/monad/btcec/v2 v2.1.2
github.com/monasuite/monad/chaincfg/chainhash v1.0.1
github.com/monasuite/monad/btcec/v2 v2.1.3
github.com/monasuite/monad/chaincfg/chainhash v1.0.2
github.com/monasuite/monad/monautil v1.1.0
)

replace github.com/monasuite/monad/monautil => ../

replace github.com/monasuite/monad => ../..

replace github.com/monasuite/monad/chaincfg/chainhash => ../../chaincfg/chainhash

replace github.com/monasuite/monad/btcec/v2 => ../../btcec
5 changes: 5 additions & 0 deletions monautil/psbt/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ=
github.com/kkdai/bstream v1.0.0/go.mod h1:FDnDOHt5Yx4p3FaHcioFT0QjDOtgUpvjeZqAs+NVZZA=
github.com/monasuite/monad/btcec/v2 v2.1.3 h1:TfCTFxEHLr+jSfzvFiux7CONiGZwPlCkg+P7TWZOdmc=
github.com/monasuite/monad/btcec/v2 v2.1.3/go.mod h1:XGc5eY42XX3WLnU7/Ntu0GjRx7L/bmhCjhAF4xKcVy8=
github.com/monasuite/monad/chaincfg/chainhash v1.0.1/go.mod h1:EeTDpYGmOWLFkKhF+EzOI3ESfTDpu44E10mysOrpVgI=
github.com/monasuite/monad/chaincfg/chainhash v1.0.2 h1:JcHggux+DO3oAN79xe57edCXHNwLc5lkNizUiAtDC9E=
github.com/monasuite/monad/chaincfg/chainhash v1.0.2/go.mod h1:EeTDpYGmOWLFkKhF+EzOI3ESfTDpu44E10mysOrpVgI=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
Expand Down
1 change: 1 addition & 0 deletions monautil/psbt/psbt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var validPsbtHex = map[int]string{
3: "70736274ff0100a00200000002ab0949a08c5af7c49b8212f417e2f15ab3f5c33dcf153821a8139f877a5b7be40000000000feffffffab0949a08c5af7c49b8212f417e2f15ab3f5c33dcf153821a8139f877a5b7be40100000000feffffff02603bea0b000000001976a914768a40bbd740cbe81d988e71de2a4d5c71396b1d88ac8e240000000000001976a9146f4620b553fa095e721b9ee0efe9fa039cca459788ac00000000000100df0200000001268171371edff285e937adeea4b37b78000c0566cbb3ad64641713ca42171bf6000000006a473044022070b2245123e6bf474d60c5b50c043d4c691a5d2435f09a34a7662a9dc251790a022001329ca9dacf280bdf30740ec0390422422c81cb45839457aeb76fc12edd95b3012102657d118d3357b8e0f4c2cd46db7b39f6d9c38d9a70abcb9b2de5dc8dbfe4ce31feffffff02d3dff505000000001976a914d0c59903c5bac2868760e90fd521a4665aa7652088ac00e1f5050000000017a9143545e6e33b832c47050f24d3eeb93c9c03948bc787b32e13000001012000e1f5050000000017a9143545e6e33b832c47050f24d3eeb93c9c03948bc787010416001485d13537f2e265405a34dbafa9e3dda01fb8230800220202ead596687ca806043edc3de116cdf29d5e9257c196cd055cf698c8d02bf24e9910b4a6ba670000008000000080020000800022020394f62be9df19952c5587768aeb7698061ad2c4a25c894f47d8c162b4d7213d0510b4a6ba6700000080010000800200008000",
4: "70736274ff0100550200000001279a2323a5dfb51fc45f220fa58b0fc13e1e3342792a85d7e36cd6333b5cbc390000000000ffffffff01a05aea0b000000001976a914ffe9c0061097cc3b636f2cb0460fa4fc427d2b4588ac0000000000010120955eea0b0000000017a9146345200f68d189e1adc0df1c4d16ea8f14c0dbeb87220203b1341ccba7683b6af4f1238cd6e97e7167d569fac47f1e48d47541844355bd4646304302200424b58effaaa694e1559ea5c93bbfd4a89064224055cdf070b6771469442d07021f5c8eb0fea6516d60b8acb33ad64ede60e8785bfb3aa94b99bdf86151db9a9a010104220020771fd18ad459666dd49f3d564e3dbc42f4c84774e360ada16816a8ed488d5681010547522103b1341ccba7683b6af4f1238cd6e97e7167d569fac47f1e48d47541844355bd462103de55d1e1dac805e3f8a58c1fbf9b94c02f3dbaafe127fefca4995f26f82083bd52ae220603b1341ccba7683b6af4f1238cd6e97e7167d569fac47f1e48d47541844355bd4610b4a6ba67000000800000008004000080220603de55d1e1dac805e3f8a58c1fbf9b94c02f3dbaafe127fefca4995f26f82083bd10b4a6ba670000008000000080050000800000",
5: "70736274ff01003f0200000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000ffffffff010000000000000000036a010000000000000a0f0102030405060708090f0102030405060708090a0b0c0d0e0f0000",
6: "70736274ff01003f0200000001ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000ffffffff010000000000000000036a010000000000002206030d097466b7f59162ac4d90bf65f2a31a8bad82fcd22e98138dcf279401939bd104ffffffff0a0f0102030405060708090f0102030405060708090a0b0c0d0e0f0000",
}

// These are all invalid PSBTs for the indicated
Expand Down

0 comments on commit 9824cf7

Please sign in to comment.