UNPKG

1.4 kBMarkdownView Raw
1# UnspentOutput
2
3`bitcore.Transaction.UnspentOutput` is a class with stateless instances that provides information about an unspent output:
4
5- Transaction ID and output index
6- The "scriptPubKey", the script included in the output
7- Amount of satoshis associated
8- Address, if available
9
10## Parameters
11
12The 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:
13
14- `scriptPubKey`: just `script` is also accepted
15- `amount`: expected value in BTC. If the `satoshis` alias is used, make sure to use satoshis instead of BTC.
16- `vout`: this is the index of the output in the transaction, renamed to `outputIndex`
17- `txid`: `txId`
18
19## Example
20
21```javascript
22var utxo = new UnspentOutput({
23 "txid" : "a0a08e397203df68392ee95b3f08b0b3b3e2401410a38d46ae0874f74846f2e9",
24 "vout" : 0,
25 "address" : "mgJT8iegL4f9NCgQFeFyfvnSw1Yj4M5Woi",
26 "scriptPubKey" : "76a914089acaba6af8b2b4fb4bed3b747ab1e4e60b496588ac",
27 "amount" : 0.00070000
28});
29var utxo = new UnspentOutput({
30 "txId" : "a0a08e397203df68392ee95b3f08b0b3b3e2401410a38d46ae0874f74846f2e9",
31 "outputIndex" : 0,
32 "address" : "mgJT8iegL4f9NCgQFeFyfvnSw1Yj4M5Woi",
33 "script" : "76a914089acaba6af8b2b4fb4bed3b747ab1e4e60b496588ac",
34 "satoshis" : 70000
35});
36```