Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
feat/SPV-938: temp commit 2
Browse files Browse the repository at this point in the history
  • Loading branch information
yarex-4chain committed Jul 25, 2024
1 parent 3c3fd57 commit 2e14b2d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
20 changes: 9 additions & 11 deletions broadcast/internal/arc/arc_submit_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@ 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"
)

// TODO: NewTxFromString - No direct replacement
// TODO: NewTxFromBytes - not found
// TODO: Input - not found (TransactionInput?)
trx "github.com/bitcoin-sv/go-sdk/transaction"
)

type SubmitTxRequest struct {
RawTx string `json:"rawTx"`
Expand Down Expand Up @@ -265,9 +262,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 {
Expand All @@ -277,12 +274,12 @@ func rawTxRequest(arc *ArcClient, rawTx string) (*SubmitTxRequest, error) {
}

request := &SubmitTxRequest{
RawTx: hex.EncodeToString(transaction.ExtendedBytes()),
RawTx: hex.EncodeToString(transaction.Bytes()),
}
return request, nil
}

func updateUtxoWithMissingData(arc *ArcClient, input *bt.Input) error {
func updateUtxoWithMissingData(arc *ArcClient, input *trx.TransactionInput) error {
txid := input.PreviousTxIDStr()
pld := httpclient.NewPayload(
httpclient.GET,
Expand All @@ -307,11 +304,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)
}

// TODO:
o := actualTx.Outputs[input.PreviousTxOutIndex]

Check failure on line 313 in broadcast/internal/arc/arc_submit_tx.go

View workflow job for this annotation

GitHub Actions / test-and-lint

input.PreviousTxOutIndex undefined (type *"github.com/bitcoin-sv/go-sdk/transaction".TransactionInput has no field or method PreviousTxOutIndex)
input.PreviousTxScript = o.LockingScript

Check failure on line 314 in broadcast/internal/arc/arc_submit_tx.go

View workflow job for this annotation

GitHub Actions / test-and-lint

input.PreviousTxScript undefined (type *"github.com/bitcoin-sv/go-sdk/transaction".TransactionInput has no field or method PreviousTxScript)
input.PreviousTxSatoshis = o.Satoshis

Check failure on line 315 in broadcast/internal/arc/arc_submit_tx.go

View workflow job for this annotation

GitHub Actions / test-and-lint

input.PreviousTxSatoshis undefined (type *"github.com/bitcoin-sv/go-sdk/transaction".TransactionInput has no field or method PreviousTxSatoshis)
Expand Down
5 changes: 4 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
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
Expand All @@ -9,6 +11,7 @@ require (
)

require (
github.com/bitcoin-sv/go-sdk v0.0.0-20240723152403-6fa5c8714bb9 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/libsv/go-bk v0.1.6 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
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/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.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down

0 comments on commit 2e14b2d

Please sign in to comment.