generated from mrz1836/go-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(SPV-1398): change outline response to be prepared for BEEF and R…
…aw formatting of transaction.
- Loading branch information
1 parent
924bdb9
commit d3b0e2a
Showing
15 changed files
with
132 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package bsv | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/bitcoin-sv/go-sdk/transaction" | ||
"github.com/bitcoin-sv/spv-wallet/engine/spverrors" | ||
) | ||
|
||
// TxHex is a hex representation of a transaction. | ||
type TxHex string | ||
|
||
// IsBEEF checks if the transaction hex is a BEEF hex. | ||
func (h TxHex) IsBEEF() bool { | ||
return strings.HasPrefix(string(h), "0100BEEF") || strings.HasPrefix(string(h), "0100beef") | ||
} | ||
|
||
// IsRawTx checks if the transaction hex is a raw transaction hex. | ||
func (h TxHex) IsRawTx() bool { | ||
return !h.IsBEEF() | ||
} | ||
|
||
// ToBEEFTransaction converts the transaction hex to a BEEF transaction. | ||
func (h TxHex) ToBEEFTransaction() (*transaction.Transaction, error) { | ||
if !h.IsBEEF() { | ||
return nil, spverrors.Newf("transaction hex is not a BEEF hex") | ||
} | ||
return transaction.NewTransactionFromBEEFHex(string(h)) | ||
Check failure on line 28 in engine/v2/bsv/transaction_hex.go GitHub Actions / Lint for errors
Check failure on line 28 in engine/v2/bsv/transaction_hex.go GitHub Actions / Lint for errors
|
||
} | ||
|
||
// Format returns the name of the format of the transaction hex. | ||
func (h TxHex) Format() string { | ||
if h.IsBEEF() { | ||
return "BEEF" | ||
} | ||
return "RAW" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.