Esteban Ordano
10 years ago
6 changed files with 149 additions and 4 deletions
@ -0,0 +1,34 @@ |
|||||
|
title: Insight Explorer |
||||
|
description: Allows users to fetch information about the state of the blockchain from a trusted Insight server. |
||||
|
--- |
||||
|
# Insight |
||||
|
|
||||
|
## Description |
||||
|
|
||||
|
`bitcore.explorers.Insight` is a simple agent to perform queries to the blockchain. There are currently two methods (the API will grow as features are requested): `getUnspentUtxos` and `broadcast`. |
||||
|
|
||||
|
### Retrieving Unspent UTXOs for an Address (or set of) |
||||
|
|
||||
|
```javascript |
||||
|
var insight = new Insight(); |
||||
|
insight.getUnspentUtxos('1Bitcoin...', function(err, utxos) { |
||||
|
if (err) { |
||||
|
// Handle errors... |
||||
|
} else { |
||||
|
// Maybe use the UTXOs to create a transaction |
||||
|
} |
||||
|
}); |
||||
|
``` |
||||
|
|
||||
|
### Broadcasting a Transaction |
||||
|
|
||||
|
```javascript |
||||
|
var insight = new Insight(); |
||||
|
insight.broadcast(tx, function(err, returnedTxId) { |
||||
|
if (err) { |
||||
|
// Handle errors... |
||||
|
} else { |
||||
|
// Mark the transaction as broadcasted |
||||
|
} |
||||
|
}); |
||||
|
``` |
@ -0,0 +1,39 @@ |
|||||
|
title: UnspentOutput |
||||
|
description: A stateless model to represent an unspent output and associated information. |
||||
|
--- |
||||
|
# UnspentOutput |
||||
|
|
||||
|
## Description |
||||
|
|
||||
|
`bitcore.Transaction.UnspentOutput` is a class with stateless instances that provides information about an unspent output: |
||||
|
- Transaction ID and output index |
||||
|
- The "scriptPubKey", the script included in the output |
||||
|
- Amount of satoshis associated |
||||
|
- Address, if available |
||||
|
|
||||
|
## Parameters |
||||
|
|
||||
|
The 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: |
||||
|
- `scriptPubKey`: just `script` is also accepted |
||||
|
- `amount`: expected value is in BTC, but also `satoshis` is accepted |
||||
|
- `vout`: this is the index of the output in the transaction, renamed to `outputIndex` |
||||
|
- `txid`: `txId` |
||||
|
|
||||
|
## Example |
||||
|
|
||||
|
```javascript |
||||
|
var utxo = new UnspentOutput({ |
||||
|
"txid" : "a0a08e397203df68392ee95b3f08b0b3b3e2401410a38d46ae0874f74846f2e9", |
||||
|
"vout" : 0, |
||||
|
"address" : "mgJT8iegL4f9NCgQFeFyfvnSw1Yj4M5Woi", |
||||
|
"scriptPubKey" : "76a914089acaba6af8b2b4fb4bed3b747ab1e4e60b496588ac", |
||||
|
"amount" : 0.00070000 |
||||
|
}); |
||||
|
var utxo = new UnspentOutput({ |
||||
|
"txId" : "a0a08e397203df68392ee95b3f08b0b3b3e2401410a38d46ae0874f74846f2e9", |
||||
|
"outputIndex" : 0, |
||||
|
"address" : "mgJT8iegL4f9NCgQFeFyfvnSw1Yj4M5Woi", |
||||
|
"script" : "76a914089acaba6af8b2b4fb4bed3b747ab1e4e60b496588ac", |
||||
|
"satoshis" : 70000 |
||||
|
}); |
||||
|
``` |
Loading…
Reference in new issue