From a2041d5790a2f9157fc6d439ef386f61c703c51c Mon Sep 17 00:00:00 2001 From: Matias Alejo Garcia Date: Sat, 15 Mar 2014 21:12:23 -0300 Subject: [PATCH] add TX signing. Support to p2pubkeyhash --- Transaction.js | 117 +++++++++++++++++++++++++++++++++++-- test/data/unspentSign.json | 6 +- test/test.Transaction.js | 35 ++++++++++- 3 files changed, 146 insertions(+), 12 deletions(-) diff --git a/Transaction.js b/Transaction.js index 4fcccb1..3b58233 100644 --- a/Transaction.js +++ b/Transaction.js @@ -12,6 +12,8 @@ var Step = imports.Step || require('step'); var buffertools = imports.buffertools || require('buffertools'); var error = imports.error || require('./util/error'); var networks = imports.networks || require('./networks'); +var WalletKey = imports.WalletKey || require('./WalletKey'); +var PrivateKey = imports.PrivateKey || require('./PrivateKey'); var COINBASE_OP = Buffer.concat([util.NULL_HASH, new Buffer('FFFFFFFF', 'hex')]); var DEFAULT_FEE = 0.0001; @@ -780,12 +782,12 @@ Transaction._scriptForAddress = function (addressString) { * * (TODO: should we use uBTC already?) * - * If not remainderAddress is given, and there is a remainderAddress - * first in address will be used. (TODO: is this is reasoable?) + * If no remainderAddress is given, and there is a remainderAddress + * first in address will be used. (TODO: is this is reasonable?) + * + * The address from the inputs will be added to the Transaction object + * for latter signing * - * TODO add exceptions for validations: - * out address - ins amount > out amount - fees < maxFees - * + more? */ Transaction.create = function (ins, outs, opts) { @@ -798,6 +800,8 @@ Transaction.create = function (ins, outs, opts) { txobj.ins = []; txobj.outs = []; + var inputMap = []; + var l = ins.length; var valueInSat = bignum(0); for(var i=0; i