mirror of
https://github.com/Permissionless-Software-Foundation/bch-js.git
synced 2026-09-21 16:51:59 -07:00
Merge pull request #261 from Permissionless-Software-Foundation/ct-unstable
feat(Utxo.get()): Creating infoUtxo category for utxos less than 1000…
This commit is contained in:
+9
-1
@@ -177,8 +177,15 @@ class UTXO {
|
|||||||
// Hydrate the UTXOs with additional token data.
|
// Hydrate the UTXOs with additional token data.
|
||||||
type1TokenUtxos = await this.hydrateTokenData(type1TokenUtxos)
|
type1TokenUtxos = await this.hydrateTokenData(type1TokenUtxos)
|
||||||
|
|
||||||
|
// Collect BCH UTXOs above 1000 sats
|
||||||
|
const bchUtxos = utxos.filter(x => x.isSlp === false && x.value > 1000)
|
||||||
|
|
||||||
|
// Collect all BCH UTXOs at 1000 sats or smaller
|
||||||
|
// The prevents SLP tokens, BCMR, and other 'colored' UTXOs from being
|
||||||
|
// accidentally included into normal BCH transactions.
|
||||||
|
const infoUtxos = utxos.filter(x => x.isSlp === false && x.value <= 1000)
|
||||||
|
|
||||||
// Collect and hydrate any type1 baton UTXOs
|
// Collect and hydrate any type1 baton UTXOs
|
||||||
const bchUtxos = utxos.filter(x => x.isSlp === false)
|
|
||||||
let type1BatonUtxos = utxos.filter(
|
let type1BatonUtxos = utxos.filter(
|
||||||
x => x.isSlp === true && x.type === 'baton' && x.tokenType === 1
|
x => x.isSlp === true && x.type === 'baton' && x.tokenType === 1
|
||||||
)
|
)
|
||||||
@@ -208,6 +215,7 @@ class UTXO {
|
|||||||
const outObj = {
|
const outObj = {
|
||||||
address: addr,
|
address: addr,
|
||||||
bchUtxos,
|
bchUtxos,
|
||||||
|
infoUtxos,
|
||||||
slpUtxos: {
|
slpUtxos: {
|
||||||
type1: {
|
type1: {
|
||||||
tokens: type1TokenUtxos,
|
tokens: type1TokenUtxos,
|
||||||
|
|||||||
@@ -142,7 +142,8 @@ describe('#utxo', () => {
|
|||||||
assert.property(result.slpUtxos, 'nft')
|
assert.property(result.slpUtxos, 'nft')
|
||||||
assert.property(result, 'nullUtxos')
|
assert.property(result, 'nullUtxos')
|
||||||
|
|
||||||
assert.equal(result.bchUtxos.length, 4)
|
assert.equal(result.bchUtxos.length, 1)
|
||||||
|
assert.equal(result.infoUtxos.length, 3)
|
||||||
assert.equal(result.slpUtxos.type1.tokens.length, 1)
|
assert.equal(result.slpUtxos.type1.tokens.length, 1)
|
||||||
assert.equal(result.slpUtxos.type1.mintBatons.length, 1)
|
assert.equal(result.slpUtxos.type1.mintBatons.length, 1)
|
||||||
assert.equal(result.nullUtxos.length, 0)
|
assert.equal(result.nullUtxos.length, 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user