TxBuilder class

Transaction Builder

Constructors

TxBuilder({Tx? tx, List<TxIn>? txIns, List<TxOut>? txOuts, TxOutMap? uTxOutMap, SigOperations? sigOperations, Script? changeScript, BigIntX? changeAmountBn, BigIntX? feeAmountBn, num? feePerKbNum, int? nLockTime, int? versionBytesNum, int? sigsPerInput, int? dust, bool? dustChangeToFees, HashCache? hashCache})

Properties

changeAmountBn BigIntX?
getter/setter pair
changeScript Script?
getter/setter pair
dust int
getter/setter pair
dustChangeToFees bool
getter/setter pair
feeAmountBn BigIntX?
getter/setter pair
feePerKbNum num
getter/setter pair
hashCache HashCache
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
nLockTime int
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sigOperations SigOperations
getter/setter pair
sigsPerInput int
getter/setter pair
tx Tx
getter/setter pair
txIns List<TxIn>
getter/setter pair
txOuts List<TxOut>
getter/setter pair
uTxOutMap TxOutMap
getter/setter pair
versionBytesNum int
getter/setter pair

Methods

addSigOperation({required List<int> txHashBuf, int? txOutNum, int? nScriptChunk, String? type, String? addressStr, int? nHashType}) TxBuilder
build({bool useAllInputs = false}) TxBuilder
Builds the transaction and adds the appropriate fee by subtracting from the change output. Note that by default the TxBuilder will use as many inputs as necessary to pay the output amounts and the required fee. The TxBuilder will not necessarily us all the inputs. To force the TxBuilder to use all the inputs (such as if you wish to spend the entire balance of a wallet), set the argument useAllInputs = true.
buildInputs({BigIntX? outAmountBn, int extraInputsNum = 0}) BigIntX
buildOutputs() BigIntX
estimateFee([BigIntX? extraFeeAmount]) BigIntX
estimateSize() int
fillSig({required int nIn, int? nScriptChunk, Sig? sig}) TxBuilder
fromJSON(Map json) TxBuilder
getSig({KeyPair? keyPair, int? nHashType, int? nIn, Script? subScript, int flags = Tx.SCRIPT_ENABLE_SIGHASH_FORKID}) Sig
Sign an input, but do not fill the signature into the transaction. Return the signature.
getSigWithUnlockingScriptHexs({KeyPair? keyPair, int? nHashType, required int nIn, Script? subScript, int flags = Tx.SCRIPT_ENABLE_SIGHASH_FORKID, required List<String> unlockingScriptHexs, BigIntX? valueBn}) TxBuilder
Sign an input, but do not fill the signature into the transaction. Return the signature.
importPartiallySignedTx(Tx tx, [TxOutMap? uTxOutMap, SigOperations? sigOperations]) TxBuilder
Import a transaction partially signed by someone else. The only thing you can do after this is sign one or more inputs. Usually used for multisig transactions. uTxOutMap is optional. It is not necessary so long as you pass in the txOut when you sign. You need to know the output when signing an input, including the script in the output, which is why this is necessary when signing an input.
inputFromPubKeyHash({List<int>? txHashBuf, int? txOutNum, TxOut? txOut, PubKey? pubKey, int? nSequence, int? nHashType}) TxBuilder
Pay "from" a pubKeyHash output - in other words, add an input to the transaction.
inputFromScript({List<int>? txHashBuf, int? txOutNum, TxOut? txOut, Script? script, int? nSequence}) TxBuilder
Pay "from" a script - in other words, add an input to the transaction.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
outputToAddress({BigIntX? valueBn, Address? addr}) TxBuilder
An address to send funds to, along with the amount. The amount should be denominated in satoshis, not bitcoins.
outputToScript({BigIntX? valueBn, Script? script}) TxBuilder
A script to send funds to, along with the amount. The amount should be denominated in satoshis, not bitcoins.
sendDustChangeToFees([bool dustChangeToFees = false]) TxBuilder
Sometimes one of your outputs or the change output will be less than dust. Values less than dust cannot be broadcast. If you are OK with sending dust amounts to fees, then set this value to true. We preferentially send all dust to the change if possible. However, that might not be possible if the change itself is less than dust, in which case all dust goes to fees.
setChangeAddress(Address changeAddress) TxBuilder
setChangeScript(Script changeScript) TxBuilder
setDust([int? dust]) TxBuilder
Sometimes one of your outputs or the change output will be less than dust. Values less than dust cannot be broadcast. If you are OK with sending dust amounts to fees, then set this value to true.
setFeePerKbNum(num feePerKbNum) TxBuilder
setNLocktime(int nLockTime) TxBuilder
nLockTime is an unsigned integer.
setVersion(int versionBytesNum) TxBuilder
signTxIn({required int nIn, KeyPair? keyPair, TxOut? txOut, int? nScriptChunk, int? nHashType = Sig.SIGHASH_ALL | Sig.SIGHASH_FORKID, int flags = Tx.SCRIPT_ENABLE_SIGHASH_FORKID}) TxBuilder
Sign ith input with keyPair and insert the signature into the transaction. This method only works for some standard transaction types. For non-standard transaction types, use getSig.
signWithKeyPairs(List<KeyPair?> keyPairs) TxBuilder
sort() TxBuilder
toJSON() Map
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

allSigsPresent(int m, Script script) bool
Check if all signatures are present in a multisig input script.
removeBlankSigs(Script script) → dynamic
Remove blank signatures in a multisig input script.