@xchainjs/xchain-utxo-providers 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # XChainJS API UTXO providers Interface
2
2
 
3
- A specification for a generalised interface for api providers, to be used by XChainJS implementations. The providers should not have any functionality to generate a key, instead, the `asgardex-crypto` library should be used to ensure cross-chain compatible keystores are handled. The providers is only ever passed a master BIP39 phrase, from which a temporary key and address is decoded.
3
+ A specification for a generalised interface for api providers, to be used by XChainJS implementations. The providers should not have any functionality to generate a key, instead, the `xchain-crypto` library should be used to ensure cross-chain compatible keystores are handled. The providers is only ever passed a master BIP39 phrase, from which a temporary key and address is decoded.
4
4
 
5
5
  ## Documentation
6
6
 
package/lib/index.esm.js CHANGED
@@ -632,7 +632,7 @@ class HaskoinProvider {
632
632
  network: this.haskoinNetwork,
633
633
  address,
634
634
  });
635
- const confirmedUnspent = allUnspent.filter((i) => i.block); //if it has a block noumber it's been confirmed
635
+ const confirmedUnspent = allUnspent.filter((i) => i.block && !i.block.mempool);
636
636
  return this.mapUTXOs(confirmedUnspent);
637
637
  });
638
638
  }
@@ -994,7 +994,9 @@ class BlockcypherProvider {
994
994
  unspentOnly,
995
995
  });
996
996
  //remove duplicates
997
- const txs = response.txrefs.map((i) => i.tx_hash);
997
+ const txs = [];
998
+ response.txrefs && txs.push(...response.txrefs.map((i) => i.tx_hash));
999
+ response.unconfirmed_txrefs && txs.push(...response.unconfirmed_txrefs.map((i) => i.tx_hash));
998
1000
  const uniqTxs = [...new Set(txs)];
999
1001
  const start = offset >= uniqTxs.length ? uniqTxs.length : offset;
1000
1002
  const end = offset + limit >= uniqTxs.length ? uniqTxs.length : offset + limit;
package/lib/index.js CHANGED
@@ -641,7 +641,7 @@ class HaskoinProvider {
641
641
  network: this.haskoinNetwork,
642
642
  address,
643
643
  });
644
- const confirmedUnspent = allUnspent.filter((i) => i.block); //if it has a block noumber it's been confirmed
644
+ const confirmedUnspent = allUnspent.filter((i) => i.block && !i.block.mempool);
645
645
  return this.mapUTXOs(confirmedUnspent);
646
646
  });
647
647
  }
@@ -1003,7 +1003,9 @@ class BlockcypherProvider {
1003
1003
  unspentOnly,
1004
1004
  });
1005
1005
  //remove duplicates
1006
- const txs = response.txrefs.map((i) => i.tx_hash);
1006
+ const txs = [];
1007
+ response.txrefs && txs.push(...response.txrefs.map((i) => i.tx_hash));
1008
+ response.unconfirmed_txrefs && txs.push(...response.unconfirmed_txrefs.map((i) => i.tx_hash));
1007
1009
  const uniqTxs = [...new Set(txs)];
1008
1010
  const start = offset >= uniqTxs.length ? uniqTxs.length : offset;
1009
1011
  const end = offset + limit >= uniqTxs.length ? uniqTxs.length : offset + limit;
@@ -75,7 +75,10 @@ export type GetBalanceDTO = {
75
75
  final_n_tx: number;
76
76
  };
77
77
  export type GetTxsDTO = {
78
- txrefs: AddressTxDTO[];
78
+ txrefs?: AddressTxDTO[];
79
+ unconfirmed_txrefs?: {
80
+ tx_hash: string;
81
+ }[];
79
82
  };
80
83
  export type BroadcastDTO = {
81
84
  tx: {
@@ -107,6 +107,7 @@ export type TxUnspent = {
107
107
  block: {
108
108
  height: number;
109
109
  position: number;
110
+ mempool: number;
110
111
  };
111
112
  index: number;
112
113
  txid: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xchainjs/xchain-utxo-providers",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/index.esm.js",