mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2025-02-14 21:10:32 +01:00
fulfillment null for test_cryptocondition
This commit is contained in:
parent
d0b059829f
commit
35be96e31d
@ -26,7 +26,9 @@ export default function makeTransaction(operation, asset, metadata = null, outpu
|
||||
tx.outputs = outputs
|
||||
|
||||
// Hashing must be done after, as the hash is of the Transaction (up to now)
|
||||
tx.inputs[0].fulfillment = null
|
||||
tx.inputs.forEach((input) => {
|
||||
input.fulfillment = null
|
||||
})
|
||||
tx.id = hashTransaction(tx)
|
||||
tx.inputs = realInputs
|
||||
return tx
|
||||
|
@ -38,7 +38,7 @@ export default function makeTransferTransaction(
|
||||
'transaction_id': unspentTransaction.id,
|
||||
}
|
||||
return makeInputTemplate(fulfilledOutput.public_keys, transactionLink,
|
||||
makeFulfillment(outputs[outputIndex].public_keys))
|
||||
makeFulfillment(fulfilledOutput.public_keys))
|
||||
})
|
||||
const assetLink = {
|
||||
'id': unspentTransaction.operation === 'CREATE' ? unspentTransaction.id
|
||||
|
@ -20,13 +20,14 @@ import serializeTransactionIntoCanonicalString from './serializeTransactionIntoC
|
||||
*/
|
||||
export default function signTransaction(transaction, ...privateKeys) {
|
||||
const signedTx = clone(transaction)
|
||||
signedTx.inputs.forEach((input, index) => {
|
||||
console.log('inpuuuuut', input)
|
||||
transaction.inputs[index].fulfillment = null // OJOOO
|
||||
const serializedTransaction = serializeTransactionIntoCanonicalString(transaction)
|
||||
|
||||
transaction.inputs.forEach((input) => {
|
||||
input.fulfillment = null // OJOOO
|
||||
})
|
||||
const serializedTransaction = serializeTransactionIntoCanonicalString(transaction)
|
||||
signedTx.inputs.forEach((input) => {
|
||||
if (input.fulfillment.type === 'ed25519-sha-256') {
|
||||
const privateKey = privateKeys[index] // TODO index is not correct here. just work for some cases
|
||||
const privateKey = privateKeys[0]
|
||||
privateKeys.splice(0, 1)
|
||||
const privateKeyBuffer = new Buffer(base58.decode(privateKey))
|
||||
const ed25519Fulfillment = new cc.Ed25519Sha256()
|
||||
ed25519Fulfillment.sign(new Buffer(serializedTransaction), privateKeyBuffer)
|
||||
@ -34,8 +35,9 @@ export default function signTransaction(transaction, ...privateKeys) {
|
||||
input.fulfillment = fulfillmentUri
|
||||
} else if (input.fulfillment.type === 'threshold-sha-256') {
|
||||
const thresholdFulfillment = new cc.ThresholdSha256()
|
||||
input.fulfillment.subconditions.forEach((subcondition, indexSubcondition) => {
|
||||
const privateKey = privateKeys[index + indexSubcondition] // TODO index is not correct here. just work for some cases
|
||||
input.fulfillment.subconditions.forEach(() => {
|
||||
const privateKey = privateKeys[0]
|
||||
privateKeys.splice(0, 1)
|
||||
const privateKeyBuffer = new Buffer(base58.decode(privateKey))
|
||||
const ed25519subFulfillment = new cc.Ed25519Sha256()
|
||||
ed25519subFulfillment.sign(new Buffer(serializedTransaction), privateKeyBuffer)
|
||||
|
@ -61,8 +61,11 @@ test('Fulfillment correctly formed', t => {
|
||||
[Transaction.makeOutput(Transaction.makeEd25519Condition(alice.publicKey))],
|
||||
[0]
|
||||
)
|
||||
const msg = Transaction.serializeTransactionIntoCanonicalString(txTransfer)
|
||||
const txSigned = Transaction.signTransaction(txTransfer, alice.privateKey)
|
||||
txTransfer.inputs.forEach((input) => {
|
||||
input.fulfillment = null // OJOOO
|
||||
})
|
||||
const msg = Transaction.serializeTransactionIntoCanonicalString(txTransfer)
|
||||
t.truthy(cc.validateFulfillment(txSigned.inputs[0].fulfillment,
|
||||
txCreate.outputs[0].condition.uri,
|
||||
new Buffer(msg)))
|
||||
|
Loading…
x
Reference in New Issue
Block a user