diff --git a/broadcast/internal/arc/arc_submit_tx.go b/broadcast/internal/arc/arc_submit_tx.go index 255c6fb..62ce751 100644 --- a/broadcast/internal/arc/arc_submit_tx.go +++ b/broadcast/internal/arc/arc_submit_tx.go @@ -2,7 +2,6 @@ package arc import ( "context" - "encoding/hex" "encoding/json" "errors" "fmt" @@ -13,7 +12,8 @@ import ( arc_utils "github.com/bitcoin-sv/go-broadcast-client/broadcast/internal/arc/utils" "github.com/bitcoin-sv/go-broadcast-client/broadcast/internal/utils" "github.com/bitcoin-sv/go-broadcast-client/httpclient" - "github.com/libsv/go-bt/v2" + + trx "github.com/bitcoin-sv/go-sdk/transaction" ) type SubmitTxRequest struct { @@ -261,9 +261,9 @@ func beefTxRequest(rawTx string) (*SubmitTxRequest, error) { } func rawTxRequest(arc *ArcClient, rawTx string) (*SubmitTxRequest, error) { - transaction, err := bt.NewTxFromString(rawTx) + transaction, err := trx.NewTransactionFromHex(rawTx) if err != nil { - return nil, utils.WithCause(errors.New("rawTxRequest: bt.NewTxFromString failed"), err) + return nil, utils.WithCause(errors.New("rawTxRequest: trx.NewTransactionFromHex() failed"), err) } for _, input := range transaction.Inputs { @@ -272,14 +272,19 @@ func rawTxRequest(arc *ArcClient, rawTx string) (*SubmitTxRequest, error) { } } + hex, err := transaction.EFHex() + if err != nil { + return nil, utils.WithCause(errors.New("rawTxRequest: transaction.EFHex() failed"), err) + } + request := &SubmitTxRequest{ - RawTx: hex.EncodeToString(transaction.ExtendedBytes()), + RawTx: hex, } return request, nil } -func updateUtxoWithMissingData(arc *ArcClient, input *bt.Input) error { - txid := input.PreviousTxIDStr() +func updateUtxoWithMissingData(arc *ArcClient, input *trx.TransactionInput) error { + txid := input.SourceTXID pld := httpclient.NewPayload( httpclient.GET, fmt.Sprintf("https://junglebus.gorillapool.io/v1/transaction/get/%s", txid), @@ -303,14 +308,12 @@ func updateUtxoWithMissingData(arc *ArcClient, input *bt.Input) error { return errors.New("junglebus responded with empty tx.Transaction[]") } - actualTx, err := bt.NewTxFromBytes(tx.Transaction) + actualTx, err := trx.NewTransactionFromBytes(tx.Transaction) if err != nil { - return utils.WithCause(errors.New("converting junglebusTransaction.Transaction to bt.Tx failed"), err) + return utils.WithCause(errors.New("converting junglebusTransaction.Transaction to trx.Transaction failed"), err) } - o := actualTx.Outputs[input.PreviousTxOutIndex] - input.PreviousTxScript = o.LockingScript - input.PreviousTxSatoshis = o.Satoshis + input.SourceTransaction = actualTx return nil } diff --git a/go.mod b/go.mod index 373f398..2098ba5 100644 --- a/go.mod +++ b/go.mod @@ -1,18 +1,20 @@ module github.com/bitcoin-sv/go-broadcast-client -go 1.21.5 +go 1.22 + +toolchain go1.22.5 require ( - github.com/libsv/go-bt/v2 v2.2.5 + github.com/bitcoin-sv/go-sdk v1.1.2 github.com/rs/zerolog v1.33.0 github.com/stretchr/testify v1.9.0 ) require ( - github.com/kr/text v0.2.0 // indirect - github.com/libsv/go-bk v0.1.6 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/pkg/errors v0.9.1 // indirect golang.org/x/crypto v0.25.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) require ( diff --git a/go.sum b/go.sum index 9820a9d..5bec744 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,7 @@ +github.com/bitcoin-sv/go-sdk v0.0.0-20240723152403-6fa5c8714bb9 h1:0FzZum72lt0J+u936VdT+pUVZQ4kLdnnVFEhOMO1+Rk= +github.com/bitcoin-sv/go-sdk v0.0.0-20240723152403-6fa5c8714bb9/go.mod h1:NOAkJLbjqKOLuxJmb9ABG86ExTZp4HS8+iygiDIUps4= +github.com/bitcoin-sv/go-sdk v1.1.2 h1:LBnvqQ1NZUrzaU2l7sMW7FMWii9yqmebairfA99ZAE8= +github.com/bitcoin-sv/go-sdk v1.1.2/go.mod h1:NOAkJLbjqKOLuxJmb9ABG86ExTZp4HS8+iygiDIUps4= github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -5,14 +9,13 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/jarcoal/httpmock v1.3.1 h1:iUx3whfZWVf3jT01hQTO/Eo5sAYtB2/rqaUuOtpInww= github.com/jarcoal/httpmock v1.3.1/go.mod h1:3yb8rc4BI7TCBhFY8ng0gjuLKJNquuDNiPaZjnENuYg= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/libsv/go-bk v0.1.6 h1:c9CiT5+64HRDbzxPl1v/oiFmbvWZTuUYqywCf+MBs/c= -github.com/libsv/go-bk v0.1.6/go.mod h1:khJboDoH18FPUaZlzRFKzlVN84d4YfdmlDtdX4LAjQA= -github.com/libsv/go-bt/v2 v2.2.5 h1:VoggBLMRW9NYoFujqe5bSYKqnw5y+fYfufgERSoubog= -github.com/libsv/go-bt/v2 v2.2.5/go.mod h1:cV45+jDlPOLfhJLfpLmpQoWzrIvVth9Ao2ZO1f6CcqU= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -21,10 +24,12 @@ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWE github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/maxatome/go-testdeep v1.12.0 h1:Ql7Go8Tg0C1D/uMMX59LAoYK7LffeJQ6X2T04nTH68g= github.com/maxatome/go-testdeep v1.12.0/go.mod h1:lPZc/HAcJMP92l7yI6TRz1aZN5URwUBUAfUNvrclaNM= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= github.com/rogpeppe/go-internal v1.11.0/go.mod h1:ddIwULY96R17DhadqLgMfk9H9tvdUzkipdSkR5nkCZA= github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=