mirror of
https://github.com/bigchaindb/js-bigchaindb-driver.git
synced 2025-02-14 21:10:32 +01:00
update JS driver to sign single message
This commit is contained in:
parent
c4a2452aa7
commit
4cec46e10b
@ -4,21 +4,7 @@ import clone from 'clone';
|
|||||||
|
|
||||||
export default function serializeTransactionIntoCanonicalString(transaction, input) {
|
export default function serializeTransactionIntoCanonicalString(transaction, input) {
|
||||||
// BigchainDB signs fulfillments by serializing transactions into a "canonical" format where
|
// BigchainDB signs fulfillments by serializing transactions into a "canonical" format where
|
||||||
// each fulfillment URI is removed before sorting the remaining keys
|
|
||||||
const tx = clone(transaction);
|
const tx = clone(transaction);
|
||||||
let match;
|
|
||||||
tx.inputs.forEach((_input) => {
|
|
||||||
|
|
||||||
if (!(_input && input && _input['fulfills'] && input['fulfills']
|
|
||||||
&& !(_input['fulfills']['txid'] === input['fulfills']['txid']
|
|
||||||
&& _input['fulfills']['output'] === input['fulfills']['output']))) {
|
|
||||||
match = tx.inputs.indexOf(_input);
|
|
||||||
}
|
|
||||||
_input.fulfillment = null;
|
|
||||||
});
|
|
||||||
if (input && match >= 0 && tx.inputs) {
|
|
||||||
tx.inputs = [tx.inputs[match]];
|
|
||||||
}
|
|
||||||
// Sort the keys
|
// Sort the keys
|
||||||
return stableStringify(tx, (a, b) => (a.key > b.key ? 1 : -1));
|
return stableStringify(tx, (a, b) => (a.key > b.key ? 1 : -1));
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user