From 620f6b095355ca3de8e6a7fdb8ae08e8d4ad7a42 Mon Sep 17 00:00:00 2001 From: KonradStaniec Date: Tue, 15 Oct 2024 09:19:23 +0200 Subject: [PATCH] add additional check from btc library (#71) (#72) * add additional check from btc library --- go.mod | 3 +-- go.sum | 6 ++---- internal/utils/btc.go | 4 ++-- tests/integration_test/unbonding_test.go | 2 +- tests/testutils/datagen.go | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/go.mod b/go.mod index ab54984..d1e1e9e 100644 --- a/go.mod +++ b/go.mod @@ -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 @@ -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 diff --git a/go.sum b/go.sum index b24250c..68d8e55 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/internal/utils/btc.go b/internal/utils/btc.go index 5230d19..9ef6b44 100644 --- a/internal/utils/btc.go +++ b/internal/utils/btc.go @@ -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 diff --git a/tests/integration_test/unbonding_test.go b/tests/integration_test/unbonding_test.go index 483e33e..1784590 100644 --- a/tests/integration_test/unbonding_test.go +++ b/tests/integration_test/unbonding_test.go @@ -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) { diff --git a/tests/testutils/datagen.go b/tests/testutils/datagen.go index 27a061b..0290085 100644 --- a/tests/testutils/datagen.go +++ b/tests/testutils/datagen.go @@ -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, }, },