Transaction: remove TxIn/TxOut from API
This commit is contained in:
parent
a6b9dd9473
commit
5bd636cab7
2 changed files with 6 additions and 36 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue