Transaction: remove TxIn/TxOut from API

This commit is contained in:
Daniel Cousens 2014-05-19 14:14:07 +10:00
parent a6b9dd9473
commit 5bd636cab7
2 changed files with 6 additions and 36 deletions

View file

@ -49,18 +49,12 @@ function Transaction(doc) {
*
* Can be called with any of:
*
* - An existing TransactionIn object
* - A transaction and an index
* - A transaction hash and an index
*
* Note that this method does not sign the created input.
*/
Transaction.prototype.addInput = function (tx, outIndex) {
if (arguments[0] instanceof TransactionIn) {
this.ins.push(arguments[0])
return
}
var hash = typeof tx === "string" ? tx : tx.hash
this.ins.push(new TransactionIn({
@ -77,16 +71,10 @@ Transaction.prototype.addInput = function (tx, outIndex) {
*
* Can be called with:
*
* i) An existing TransactionOut object
* ii) An address object or a string address, and a value
*
* - An address object and a value
* - A base58 address string and a value
*/
Transaction.prototype.addOutput = function (address, value) {
if (arguments[0] instanceof TransactionOut) {
this.outs.push(arguments[0])
return
}
if (typeof address === 'string') {
address = Address.fromBase58Check(address)
}
@ -222,12 +210,12 @@ Transaction.prototype.clone = function () {
newTx.version = this.version
newTx.locktime = this.locktime
this.ins.forEach(function(txin) {
newTx.addInput(txin.clone())
newTx.ins = this.ins.map(function(txin) {
return new TransactionIn(txin)
})
this.outs.forEach(function(txout) {
newTx.addOutput(txout.clone())
newTx.outs = this.outs.map(function(txout) {
return new TransactionOut(txout)
})
return newTx

View file

@ -118,15 +118,6 @@ describe('Transaction', function() {
verifyTransactionIn()
})
it('allows a TransactionIn object to be passed in', function() {
var txCopy = tx.clone()
txCopy.addInput(prevTx, 0)
var transactionIn = txCopy.ins[0]
tx.addInput(transactionIn)
verifyTransactionIn()
})
function verifyTransactionIn() {
assert.equal(tx.ins.length, 1)
@ -151,15 +142,6 @@ describe('Transaction', function() {
verifyTransactionOut()
})
it('allows a TransactionOut object to be passed in', function() {
var txCopy = tx.clone()
txCopy.addOutput("15mMHKL96tWAUtqF3tbVf99Z8arcmnJrr3", 40000)
var transactionOut = txCopy.outs[0]
tx.addOutput(transactionOut)
verifyTransactionOut()
})
it('supports alternative networks', function() {
var addr = 'mkHJaNR7uuwRG1JrmTZsV4MszaTKjCBvCR'