UNPKG

1.4 kBMarkdownView Raw
1# UnspentOutput
2`bsv.Transaction.UnspentOutput` is a class with stateless instances that provides information about an unspent output:
3- Transaction ID and output index
4- The "scriptPubKey", the script included in the output
5- Amount of satoshis associated
6- Address, if available
7
8## Parameters
9The constructor is quite permissive with the input arguments. It can take outputs straight out of bitcoind's getunspent RPC call. Some of the names are not very informative for new users, so the UnspentOutput constructor also understands these aliases:
10- `scriptPubKey`: just `script` is also accepted
11- `amount`: expected value in BSV. If the `satoshis` alias is used, make sure to use satoshis instead of BSV.
12- `vout`: this is the index of the output in the transaction, renamed to `outputIndex`
13- `txid`: `txId`
14
15## Example
16
17```javascript
18var utxo = new UnspentOutput({
19 "txid" : "a0a08e397203df68392ee95b3f08b0b3b3e2401410a38d46ae0874f74846f2e9",
20 "vout" : 0,
21 "address" : "mgJT8iegL4f9NCgQFeFyfvnSw1Yj4M5Woi",
22 "scriptPubKey" : "76a914089acaba6af8b2b4fb4bed3b747ab1e4e60b496588ac",
23 "amount" : 0.00070000
24});
25var utxo = new UnspentOutput({
26 "txId" : "a0a08e397203df68392ee95b3f08b0b3b3e2401410a38d46ae0874f74846f2e9",
27 "outputIndex" : 0,
28 "address" : "mgJT8iegL4f9NCgQFeFyfvnSw1Yj4M5Woi",
29 "script" : "76a914089acaba6af8b2b4fb4bed3b747ab1e4e60b496588ac",
30 "satoshis" : 70000
31});
32```