Coin¶
-
interface
coin.
Coin
¶ Bitcoin Cash network operations.
-
coin.Coin.
InputIndex
()¶ Input index.
Input index expressed as a decimal number in a string. Provides support for full range specified in Bitcoin protocol. Provides comparison by value enabling use as
Map
keys.
-
coin.Coin.
InputSignature
()¶ Input signature pair.
Associates an input index to an input signature. 2 element array.
Arguments: - 1 (InputIndex) – Input index.
- 2 (Signature) – Input signature.
Examples:
const inputIndex = 4 const signature = '3044022020ea35009d17d25b8a926675ddf0045c397d3df55b0ae115ef80db7849' + '529b9302201f13bd2cbd1ca0a24e2c5ab28030aa9b7b3dcacf175652dad82fe9d5' + '973f340901' const inputSignature = [ inputIndex, signature ]
-
coin.Coin.
ParticipantAddress
()¶ Participant address pair.
Associates a Bitcoin Cash address to a named participant. 2 element array.
Arguments: Examples:
const sessionPublicKey = '020db431245713add097421a29ec3089f01587a3808d1043fee5956fc5e08effcd' const address = 'bitcoincash:qr975e2q784jnk0pq2rrk9enuywttyhxryfkyuyjq3' const participantAddress = [ sessionPublicKey, address ]
-
coin.Coin.
Signature
()¶ Transaction signature.
Signature of a SIGHASH_ALL type transaction hash. Represented as a hex string.
-
coin.Coin.
Transaction
()¶ Bitcoin Cash transaction.
Used by various methods to construct a multinput multioutput multisignature transaction over several calls.
Type and usage details implementation defined.
-
coin.Coin.
addTransactionSignature
(transaction, inputIndex, signature)¶ Add input signature to transaction.
Arguments: - transaction (Transaction) – Transaction to add signature to.
- inputIndex (InputIndex) – Index of input to add signature to.
- signature (Signature) – Input signature.
Returns: Transaction – Transaction with signature added.
-
coin.Coin.
addTransactionSignatures
(transaction, signatures)¶ Add input signatures to transaction.
Map
instances work well forsignatures
.Arguments: - transaction (Transaction) – Transaction to add signatures to.
- signatures (Iterable.<InputSignature>) – Signatures to add.
Returns: Transaction – Transaction with signatures added.
-
coin.Coin.
address
(publicKeyString, network="<mainnet>")¶ Get P2PKH address for public key.
Arguments: - publicKeyString (HexString) – Public key.
- network – Bitcoin Cash network. Type implementation defined.
Returns: CashAddr – P2PKH address for the public key.
-
coin.Coin.
broadcastTransaction
(transaction)¶ Broadcast transaction.
Submits transaction to Bitcoin Cash network.
Arguments: - transaction (Transaction) – Transaction to broadcast.
Throws: BusyError – If any other network operation is running.
Throws: If transaction submission fails.
-
coin.Coin.
makeUnsignedTransaction
(amount, fee, inputAddresses, outputAddresses, changeAddresses)¶ Make unsigned transaction.
Map
instances work well forinputAddresses
andchangeAddresses
.Set
instances work well foroutputAddresses
.Arguments: - amount (number) – Participant transaction amount in satoshis. The produced transaction will transfer this amount for each participant.
- fee (number) – Participant fee amount in satoshis. The produced transaction will charge this fee to each participant.
- inputAddresses (Iterable.<ParticipantAddress>) – Input addresses. 1 for each participant.
- outputAddresses (Iterable.<CashAddr>) – Output addresses. 1 for each participant. Participant associated with each output unspecified.
- changeAddresses (Iterable.<ParticipantAddress>) – Change output addresses. 0-1 for each participant.
Returns: Transaction – The unsigned transaction.
-
coin.Coin.
signTransactionInput
(transaction, inputIndex, privateKeyString)¶ Produce signature of transaction input.
Signs named input of provided transaction with provided private key.
Arguments: - transaction (Transaction) – Transaction to sign.
- inputIndex (InputIndex) – Index of input to sign.
- privateKeyString (HexString) – Signer private key.
Returns: Signature – Signature.
-
coin.Coin.
signTransactionInputs
(transaction, privateKeyString)¶ Produce signatures of all possible transaction inputs.
Signs all inputs of provided transaction controlled by provided private key.
Arguments: - transaction (Transaction) – Transaction to sign.
- privateKeyString (HexString) – Signer private key.
Returns: Map.<InputIndex, Signature> – Signatures. Key input index. Value signature.
-
coin.Coin.
sufficientFunds
(address, amount)¶ Verify address has sufficient funds.
Arguments: - address (CashAddr) – Bitcoin Cash address to check.
- amount (number) – Required amount in satoshis.
Throws: BusyError – If any other network operation is running.
Returns: boolean – Whether address has sufficient funds. True if address has the given amount or more.
-
coin.Coin.
verifySignature
(signature, message, publicKeyString, network="<mainnet>")¶ Verify message signature.
Arguments: Returns: boolean – Whether the signature is valid. True if from the named signer and for the given message.
-
coin.Coin.
verifyTransactionSignature
(transaction, inputIndex, signature)¶ Verify transaction input signature.
Arguments: - transaction (Transaction) – Transaction to verify signature for.
- inputIndex (InputIndex) – Input of index to verify signature of.
- signature (Signature) – Signature to verify.
Returns: boolean – Whether the signature is valid. True if for the named input of provided transaction.
-