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 publicKeys = []
|
||||||
const getPublicKeys = details => {
|
const getPublicKeys = details => {
|
||||||
if (details.type === 'ed25519-sha-256') {
|
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') {
|
} else if (details.type === 'threshold-sha-256') {
|
||||||
details.subfulfillments.map(getPublicKeys)
|
details.subfulfillments.map(getPublicKeys)
|
||||||
}
|
}
|
||||||
|
@ -19,21 +19,29 @@ test('Ed25519 condition encoding', t => {
|
|||||||
|
|
||||||
test('Threshold condition encoding', t => {
|
test('Threshold condition encoding', t => {
|
||||||
const publicKey = '4zvwRjXUKGfvwnParsHAS3HuSVzV5cA4McphgmoCtajS'
|
const publicKey = '4zvwRjXUKGfvwnParsHAS3HuSVzV5cA4McphgmoCtajS'
|
||||||
|
const ed25519 = Transaction.makeEd25519Condition(publicKey, false)
|
||||||
const condition = Transaction.makeThresholdCondition(
|
const condition = Transaction.makeThresholdCondition(
|
||||||
1, [Transaction.makeEd25519Condition(publicKey, false)])
|
1, [ed25519, ed25519])
|
||||||
const output = Transaction.makeOutput(condition)
|
const output = Transaction.makeOutput(condition)
|
||||||
const target = {
|
const target = {
|
||||||
condition: {
|
condition: {
|
||||||
details: {
|
details: {
|
||||||
type: 'threshold-sha-256',
|
type: 'threshold-sha-256',
|
||||||
threshold: 1,
|
threshold: 1,
|
||||||
subfulfillments: [{
|
subfulfillments: [
|
||||||
type: 'ed25519-sha-256',
|
{
|
||||||
public_key: publicKey,
|
type: 'ed25519-sha-256',
|
||||||
signature: null,
|
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',
|
amount: '1',
|
||||||
public_keys: [publicKey]
|
public_keys: [publicKey]
|
||||||
|
Loading…
Reference in New Issue
Block a user