Skip to content

Commit

Permalink
add additional check from btc library (#71) (#72)
Browse files Browse the repository at this point in the history
* add additional check from btc library
  • Loading branch information
KonradStaniec authored Oct 15, 2024
1 parent a598e22 commit 620f6b0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.3
toolchain go1.22.4

require (
github.com/babylonlabs-io/babylon v0.9.0
github.com/babylonlabs-io/babylon v0.12.1
github.com/babylonlabs-io/networks/parameters v0.2.2
github.com/babylonlabs-io/staking-queue-client v0.4.3
github.com/btcsuite/btcd v0.24.2
Expand Down Expand Up @@ -90,7 +90,6 @@ require (
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect
github.com/distribution/reference v0.5.0 // indirect
github.com/docker/docker v23.0.8+incompatible // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/dvsekhvalnov/jose2go v1.6.0 // indirect
github.com/emicklei/dot v1.6.1 // indirect
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ github.com/aws/aws-sdk-go v1.44.122/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX
github.com/aws/aws-sdk-go v1.44.312 h1:llrElfzeqG/YOLFFKjg1xNpZCFJ2xraIi3PqSuP+95k=
github.com/aws/aws-sdk-go v1.44.312/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/babylonlabs-io/babylon v0.9.0 h1:dHZ9wUrI5XLaO4UIwJRgiCdnzFdi5yv7dpibbu6TDv0=
github.com/babylonlabs-io/babylon v0.9.0/go.mod h1:t7B4e+ooD2oYvAxkegtNKDL9bXe+vU29a8xnCQh+UKo=
github.com/babylonlabs-io/babylon v0.12.1 h1:Qfmrq3pdDEZGq6DtMXxwiQjx0HD+t+U0cXQzsJfX15U=
github.com/babylonlabs-io/babylon v0.12.1/go.mod h1:ZOrTde9vs2xoqGTFw4xhupu2CMulnpywiuk0eh4kPOw=
github.com/babylonlabs-io/networks/parameters v0.2.2 h1:TCu39fZvjX5f6ZZrjhYe54M6wWxglNewuKu56yE+zrc=
github.com/babylonlabs-io/networks/parameters v0.2.2/go.mod h1:iEJVOzaLsE33vpP7J4u+CRGfkSIfErUAwRmgCFCBpyI=
github.com/babylonlabs-io/staking-queue-client v0.4.3 h1:wYDE/LXc9zmeliKoy602UVtSwahP2iDxoTNYuIf/WrM=
Expand Down Expand Up @@ -443,8 +443,6 @@ github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WA
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/docker v23.0.8+incompatible h1:z4ZCIwfqHgOEwhxmAWugSL1PFtPQmLP60EVhJYJPaX8=
github.com/docker/docker v23.0.8+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec=
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
Expand Down
4 changes: 2 additions & 2 deletions internal/utils/btc.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ func parseUnbondingTxHex(unbondingTxHex string) (*wire.MsgTx, error) {
return nil, fmt.Errorf("failed to decode unbonding tx from hex: %w", err)
}

if err := btcstaking.IsSimpleTransfer(unbondingTx); err != nil {
return nil, fmt.Errorf("the unbonding tx is not a simple transfer: %w", err)
if err := btcstaking.CheckPreSignedUnbondingTxSanity(unbondingTx); err != nil {
return nil, fmt.Errorf("the unbonding tx is not a valid pre-signed unbonding tx: %w", err)
}

return unbondingTx, nil
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_test/unbonding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ func TestUnbondingRequestValidation(t *testing.T) {
err = json.Unmarshal(bodyBytes, &unbondingResponse)
assert.NoError(t, err, "unmarshalling response body should not fail")
assert.Equal(t, types.ValidationError.String(), unbondingResponse.ErrorCode)
assert.Equal(t, "invalid unbonding tx hex: the unbonding tx is not a simple transfer: simple transfer tx must not be replacable", unbondingResponse.Message)
assert.Equal(t, "invalid unbonding tx hex: the unbonding tx is not a valid pre-signed unbonding tx: pre-signed tx must not be replaceable", unbondingResponse.Message)
}

func TestContentLength(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion tests/testutils/datagen.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ func GenerateRandomTx(
Hash: chainhash.HashH(bbndatagen.GenRandomByteArray(r, 10)),
Index: r.Uint32(),
},
SignatureScript: bbndatagen.GenRandomByteArray(r, 10),
SignatureScript: []byte{},
Sequence: sequence,
},
},
Expand Down

0 comments on commit 620f6b0

Please sign in to comment.