Documentation
¶
Index ¶
- Constants
- Variables
- type GivenTXSpec
- type OpCode
- type Paymail
- type PushData
- type ScriptPart
- type User
- func (f *User) Address() *script.Address
- func (f *User) DefaultPaymail() Paymail
- func (f *User) ID() string
- func (f *User) P2PKHLockingScript() *script.Script
- func (f *User) P2PKHUnlockingScriptTemplate(instructions ...bsv.CustomInstruction) *p2pkh.P2PKH
- func (f *User) PrivateKey() *ec.PrivateKey
- func (f *User) PublicKey() *ec.PublicKey
- func (f *User) XPriv() string
- func (f *User) XPrivHD() *bip32.ExtendedKey
- func (f *User) XPub() string
- func (f *User) XPubID() string
Constants ¶
const ( // PaymailDomain is the "our" paymail domain in the tests. PaymailDomain = "example.com" // PaymailDomainExternal is the "their"/external paymail domain in the tests. PaymailDomainExternal = "external.example.com" // SenderExternalPKI is the PKI of the external Sender used in fixtures SenderExternalPKI = "02ed100a85ac774757c967e2a7a8a1c7fdef901795805b494df69d7d02f663d259" // RecipientExternalPKI is the PKI of the RecipientExternal used in fixtures RecipientExternalPKI = "03bf409b6b2842150142c6b92cb11ba6a06310bdacd0ff2118a9b9da60ed994c2b" )
Variables ¶
var ( // UserWithMorePaymails is a user with more than one paymail. UserWithMorePaymails = User{ Paymails: []Paymail{ "tester@" + PaymailDomain, "second_pm@" + PaymailDomain, }, PrivKey: "xprv9s21ZrQH143K29ipDWk4vbx6cyyfpbBSj84GrmQPpaKu9Nct6KBhxmSPaGHxoAPisgd3sXKdb2kqKpgLEeAoS54CQGZC8vjoQ6tmJceATxZ", } // UserWithoutPaymail is a user without any paymail. UserWithoutPaymail = User{ PrivKey: "xprv9s21ZrQH143K4b2JYp37EzEcK55k5wQDnXaH3ooi8oq9yHEj8TCWGuVnJoQvQVyHx3eyF6DyLDiteD6G5CLdKvTcG8QwiEZPyqUcvgmj9aK", } // Sender is a user that is a sender in the tests. Sender = User{ Paymails: []Paymail{ "sender@" + PaymailDomain, }, PrivKey: "xprv9s21ZrQH143K2stnKknNEck8NZ9buundyjYCGFGS31bwApaGp7oviHYVY9YAogmgvFC8EdsbsDReydnhDXrRrSXoNoMZczV9t4oPQREAmQ3", } // RecipientInternal is a user that is a recipient from "our" server in the tests. RecipientInternal = User{ Paymails: []Paymail{ "recipient@" + PaymailDomain, }, PrivKey: "xprv9s21ZrQH143K3c3jkTBGijY5UsiHUdd3fSzRFD21c7cFduWX4m9nPrcuVrjQ76K234TFWgKF3f97HXggriPipBdhuof6bSvLGE74zCCgJds", } // RecipientExternal is a user that is a recipient from external server in the tests. RecipientExternal = User{ Paymails: []Paymail{ "recipient@" + PaymailDomainExternal, }, PrivKey: "xprvA8mj2ZL1w6Nqpi6D2amJLo4Gxy24tW9uv82nQKmamT2rkg5DgjzJZRFnW33e7QJwn65uUWSuN6YQyWrujNjZdVShPRnpNUSRVTru4cxaqfd", } // SenderExternal is a user that is a sender from external server in the tests. SenderExternal = User{ Paymails: []Paymail{ "sender@" + PaymailDomainExternal, }, PrivKey: "", } // ExternalFaucet is a user that is a faucet from external server in the tests. ExternalFaucet = User{ Paymails: []Paymail{ "faucet@" + PaymailDomainExternal, }, PrivKey: "xprv9s21ZrQH143K3N6qVJQAu4EP51qMcyrKYJLkLgmYXgz58xmVxVLSsbx2DfJUtjcnXK8NdvkHMKfmmg5AJT2nqqRWUrjSHX29qEJwBgBPkJQ", } )
var DefaultFeeUnit = bsv.FeeUnit{
Satoshis: 1,
Bytes: 1000,
}
DefaultFeeUnit is the default fee unit used in the tests.
var MockedBHSMerkleRootsData = []models.MerkleRoot{
{
BlockHeight: 0,
MerkleRoot: "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
},
{
BlockHeight: 1,
MerkleRoot: "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
},
{
BlockHeight: 2,
MerkleRoot: "9b0fc92260312ce44e74ef369f5c66bbb85848f2eddd5a7a1cde251e54ccfdd5",
},
{
BlockHeight: 3,
MerkleRoot: "999e1c837c76a1b7fbb7e57baf87b309960f5ffefbf2a9b95dd890602272f644",
},
{
BlockHeight: 4,
MerkleRoot: "df2b060fa2e5e9c8ed5eaf6a45c13753ec8c63282b2688322eba40cd98ea067a",
},
{
BlockHeight: 5,
MerkleRoot: "63522845d294ee9b0188ae5cac91bf389a0c3723f084ca1025e7d9cdfe481ce1",
},
{
BlockHeight: 6,
MerkleRoot: "20251a76e64e920e58291a30d4b212939aae976baca40e70818ceaa596fb9d37",
},
{
BlockHeight: 7,
MerkleRoot: "8aa673bc752f2851fd645d6a0a92917e967083007d9c1684f9423b100540673f",
},
{
BlockHeight: 8,
MerkleRoot: "a6f7f1c0dad0f2eb6b13c4f33de664b1b0e9f22efad5994a6d5b6086d85e85e3",
},
{
BlockHeight: 9,
MerkleRoot: "0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9",
},
{
BlockHeight: 10,
MerkleRoot: "d3ad39fa52a89997ac7381c95eeffeaf40b66af7a57e9eba144be0a175a12b11",
},
{
BlockHeight: 11,
MerkleRoot: "f8325d8f7fa5d658ea143629288d0530d2710dc9193ddc067439de803c37066e",
},
{
BlockHeight: 12,
MerkleRoot: "3b96bb7e197ef276b85131afd4a09c059cc368133a26ca04ebffb0ab4f75c8b8",
},
{
BlockHeight: 13,
MerkleRoot: "9962d5c704ec27243364cbe9d384808feeac1c15c35ac790dffd1e929829b271",
},
{
BlockHeight: 14,
MerkleRoot: "e1afd89295b68bc5247fe0ca2885dd4b8818d7ce430faa615067d7bab8640156",
},
}
MockedBHSMerkleRootsData is mocked merkle roots data on Block Header Service (BHS) side
Functions ¶
This section is empty.
Types ¶
type GivenTXSpec ¶
type GivenTXSpec interface { WithSender(sender User) GivenTXSpec WithRecipient(recipient User) GivenTXSpec WithoutSigning() GivenTXSpec WithInput(satoshis uint64) GivenTXSpec WithInputFromUTXO(tx *trx.Transaction, vout uint32) GivenTXSpec WithSingleSourceInputs(satoshis ...uint64) GivenTXSpec WithOPReturn(dataStr string) GivenTXSpec WithOutputScriptParts(parts ...ScriptPart) GivenTXSpec WithOutputScript(satoshis uint64, script *script.Script) GivenTXSpec WithP2PKHOutput(satoshis uint64) GivenTXSpec TX() *trx.Transaction InputUTXO(inputID int) bsv.Outpoint InputSourceTX(inputID int) *trx.Transaction ID() string BEEF() string RawTX() string EF() string }
GivenTXSpec is a builder for creating MOCK! transactions
NOTE: Using several inputs in a single transaction is not recommended RIGHT NOW because: in that case the resulting BEEF hex will be varying because of the order of inputs TODO: Remove this comment after the go-sdk algorithm is fixed
func GivenTX ¶
func GivenTX(t testing.TB) GivenTXSpec
GivenTX creates a new GivenTXSpec for building a MOCK! transaction
type OpCode ¶
type OpCode byte
OpCode is an alias for byte to represent an opcode and implements ScriptPart for script building
type Paymail ¶
type Paymail string
Paymail wraps a string paymail address to provide additional common methods.
func (Paymail) PublicName ¶
PublicName returns the public name of this paymail (for testing purposes, it's just the alias in uppercase).
type PushData ¶
type PushData []byte
PushData is an alias for []byte to represent push data and implements ScriptPart for script building
type ScriptPart ¶
ScriptPart is an interface for building script parts
type User ¶
User is a fixture that is representing a user of the system.
func AllUsers ¶
func AllUsers() []User
AllUsers returns all users fixtures despite it's internal or external user.
func InternalUsers ¶
func InternalUsers() []User
InternalUsers returns all users fixtures representing spv-wallet users.
func (*User) DefaultPaymail ¶
DefaultPaymail returns the default paymail of this user.
func (*User) ID ¶
ID returns the id of the user. Warning: this refers to the new-tx-flow approach where v2 user's id is effectively P2PKH address from the public key.
func (*User) P2PKHLockingScript ¶
P2PKHLockingScript returns the locking script of this user.
func (*User) P2PKHUnlockingScriptTemplate ¶
func (f *User) P2PKHUnlockingScriptTemplate(instructions ...bsv.CustomInstruction) *p2pkh.P2PKH
P2PKHUnlockingScriptTemplate returns the unlocking script template of this user.
func (*User) PrivateKey ¶
func (f *User) PrivateKey() *ec.PrivateKey
PrivateKey returns the private key of this user.
func (*User) XPrivHD ¶
func (f *User) XPrivHD() *bip32.ExtendedKey
XPrivHD returns the xpriv of this user as a HD key.