Documentation ¶
Overview ¶
Package txauthor provides transaction creation code for wallets.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddAllInputScripts ¶
func AddAllInputScripts( tx *wire.MsgTx, prevPkScripts [][]byte, inputValues []util.Amount, secrets SecretsSource) error
AddAllInputScripts modifies transaction a transaction by adding inputs scripts for each input. Previous output scripts being redeemed by each input are passed in prevPkScripts and the slice length must match the number of inputs. Private keys and redeem scripts are looked up using a SecretsSource based on the previous output script.
Types ¶
type AuthoredTx ¶
type AuthoredTx struct { Tx *wire.MsgTx PrevScripts [][]byte PrevInputValues []util.Amount TotalInput util.Amount ChangeIndex int // negative if no change }
func NewUnsignedTransaction ¶
func NewUnsignedTransaction( outputs []*wire.TxOut, relayFeePerKb util.Amount, fetchInputs InputSource, fetchChange ChangeSource) (*AuthoredTx, error)
NewUnsignedTransaction creates an unsigned transaction paying to one or more non-change outputs. An appropriate transaction fee is included based on the transaction size.
Transaction inputs are chosen from repeated calls to fetchInputs with increasing targets amounts.
If any remaining output value can be returned to the wallet via a change output without violating mempool dust rules, a P2WPKH change output is appended to the transaction outputs. Since the change output may not be necessary, fetchChange is called zero or one times to generate this script. This function must return a P2WPKH script or smaller, otherwise fee estimation will be incorrect.
If successful, the transaction, total input value spent, and all previous output scripts are returned. If the input source was unable to provide enough input value to pay for every output any any necessary fees, an InputSourceError is returned.
BUGS: Fee estimation may be off when redeeming non-compressed P2PKH outputs.
func (*AuthoredTx) AddAllInputScripts ¶
func (tx *AuthoredTx) AddAllInputScripts(secrets SecretsSource) error
AddAllInputScripts modifies an authored transaction by adding inputs scripts for each input of an authored transaction. Private keys and redeem scripts are looked up using a SecretsSource based on the previous output script.
func (*AuthoredTx) RandomizeChangePosition ¶
func (tx *AuthoredTx) RandomizeChangePosition()
RandomizeChangePosition randomizes the position of an authored transaction's change output. This should be done before signing.
type ChangeSource ¶
type InputSource ¶
type InputSourceError ¶
type InputSourceError interface { error InputSourceError() }