mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2024-11-22 17:50:09 +01:00
public_keys array is a set
This commit is contained in:
parent
6fa2b2e7e5
commit
b22cf39aa2
@ -13,7 +13,9 @@ export default function makeOutput(condition, amount = '1') {
|
||||
const publicKeys = []
|
||||
const getPublicKeys = details => {
|
||||
if (details.type === 'ed25519-sha-256') {
|
||||
publicKeys.push(details.public_key)
|
||||
if (publicKeys.indexOf(details.public_key) === -1) {
|
||||
publicKeys.push(details.public_key)
|
||||
}
|
||||
} else if (details.type === 'threshold-sha-256') {
|
||||
details.subfulfillments.map(getPublicKeys)
|
||||
}
|
||||
|
@ -19,21 +19,29 @@ test('Ed25519 condition encoding', t => {
|
||||
|
||||
test('Threshold condition encoding', t => {
|
||||
const publicKey = '4zvwRjXUKGfvwnParsHAS3HuSVzV5cA4McphgmoCtajS'
|
||||
const ed25519 = Transaction.makeEd25519Condition(publicKey, false)
|
||||
const condition = Transaction.makeThresholdCondition(
|
||||
1, [Transaction.makeEd25519Condition(publicKey, false)])
|
||||
1, [ed25519, ed25519])
|
||||
const output = Transaction.makeOutput(condition)
|
||||
const target = {
|
||||
condition: {
|
||||
details: {
|
||||
type: 'threshold-sha-256',
|
||||
threshold: 1,
|
||||
subfulfillments: [{
|
||||
type: 'ed25519-sha-256',
|
||||
public_key: publicKey,
|
||||
signature: null,
|
||||
}]
|
||||
subfulfillments: [
|
||||
{
|
||||
type: 'ed25519-sha-256',
|
||||
public_key: publicKey,
|
||||
signature: null,
|
||||
},
|
||||
{
|
||||
type: 'ed25519-sha-256',
|
||||
public_key: publicKey,
|
||||
signature: null,
|
||||
}
|
||||
]
|
||||
},
|
||||
uri: 'ni:///sha-256;VBIfZSoBprUQy-LVNAzaZ2q-eyWbrcPKtBg1PuNXIpQ?fpt=threshold-sha-256&cost=132096&subtypes=ed25519-sha-256',
|
||||
uri: 'ni:///sha-256;xTeBhQj7ae5Tym7cp83fwtkesQnhdwNwDEMIYwnf2g0?fpt=threshold-sha-256&cost=133120&subtypes=ed25519-sha-256',
|
||||
},
|
||||
amount: '1',
|
||||
public_keys: [publicKey]
|
||||
|
Loading…
Reference in New Issue
Block a user