Comparing version 3.6.0 to 3.7.0
{ | ||
"name": "blockcast", | ||
"version": "3.6.0", | ||
"version": "3.7.0", | ||
"description": "A multi-transaction protocol for storing data in the Bitcoin blockchain.", | ||
@@ -32,11 +32,11 @@ "main": "./src/index.js", | ||
"jasmine-node": "^1.14.5", | ||
"mem-common-blockchain": "0.0.2", | ||
"mem-common-blockchain": "^1.5.0", | ||
"node-env-file": "^0.1.7", | ||
"test-common-wallet": "^1.2.1" | ||
"test-common-wallet": "^1.3.1" | ||
}, | ||
"dependencies": { | ||
"async": "^1.4.2", | ||
"bitcoin-tx-hex-to-json": "^1.0.0", | ||
"bitcoin-tx-hex-to-json": "^1.2.0", | ||
"bitcoinjs-lib": "^1.5.8" | ||
} | ||
} |
@@ -14,2 +14,3 @@ var async = require('async') | ||
var fee = options.fee | ||
var destinationValue = options.destinationValue || 0 | ||
var unspentOutputs = options.unspentOutputs | ||
@@ -36,3 +37,7 @@ var unspentValue = 0 | ||
} | ||
tx.addOutput(address, unspentValue - fee) | ||
var change = unspentValue - fee - destinationValue | ||
tx.addOutput(address, change) | ||
if (options.skipSign) { | ||
return callback(false, tx) | ||
} | ||
options.signTransaction(tx, txInputIndex, function (err, signedTx) { | ||
@@ -130,5 +135,13 @@ if (err) { } // TODO | ||
var primaryTxHex = options.primaryTxHex | ||
var usedTxids = [] | ||
var destinationAddress = options.destinationAddress | ||
var destinationValue = options.value || 0 | ||
if (primaryTxHex) { | ||
var primaryTx = txHexToJSON(primaryTxHex) | ||
usedTxids = primaryTx.vin.map(function (input) { return input.txid }) | ||
} | ||
var signPrimaryTxHex = options.signPrimaryTxHex | ||
var commonWallet = options.commonWallet | ||
var address = commonWallet.address | ||
var returnWithUnsignedPrimary = options.returnWithUnsignedPrimary | ||
var fee = options.fee || 1000 | ||
@@ -155,3 +168,3 @@ var commonBlockchain = options.commonBlockchain | ||
var totalCost = payloadsLength * fee | ||
var totalCost = payloadsLength * fee + destinationValue | ||
var existingUnspents = [] | ||
@@ -171,2 +184,5 @@ var unspentValue = 0 | ||
var unspentOutput = unspentOutputs[i] | ||
if (usedTxids.indexOf(unspentOutput.txid) > -1) { | ||
continue | ||
} | ||
unspentValue += unspentOutput.value | ||
@@ -181,2 +197,7 @@ existingUnspents.push(unspentOutput) | ||
if (err) { } // TODO | ||
if (signedTransactionsCounter === 0 && destinationAddress && destinationValue) { | ||
signedTx.addOutput(destinationAddress, destinationValue) | ||
} | ||
var signedTxBuilt = signedTx.buildIncomplete() | ||
@@ -216,2 +237,4 @@ var signedTxHex = signedTxBuilt.toHex() | ||
var skipSign = returnWithUnsignedPrimary && signedTransactionsCounter === 0 | ||
loadAndSignTransaction({ | ||
@@ -222,3 +245,5 @@ fee: fee, | ||
address: address, | ||
signTransaction: options.signTransaction | ||
skipSign: skipSign, | ||
signTransaction: options.signTransaction, | ||
destinationValue: (signedTransactionsCounter === 0) ? destinationValue : false | ||
}, signedTransactionResponse) | ||
@@ -252,3 +277,4 @@ } | ||
signTransaction: options.signTransaction, | ||
signPrimaryTxHex: signPrimaryTxHex | ||
signPrimaryTxHex: signPrimaryTxHex, | ||
destinationValue: (signedTransactionsCounter === 0) ? destinationValue : false | ||
} | ||
@@ -255,0 +281,0 @@ |
@@ -12,2 +12,4 @@ var txHexToJSON = require('bitcoin-tx-hex-to-json') | ||
var primaryTxHex = options.primaryTxHex | ||
var destinationAddress = options.destinationAddress | ||
var value = options.value | ||
var signPrimaryTxHex = options.signPrimaryTxHex | ||
@@ -17,13 +19,3 @@ var propagationStatus = options.propagationStatus || function () {} | ||
var retryMax = options.retryMax || 5 | ||
var id = options.id || 0 // THINK ABOUT THIS!!! Maybe go through their recent transactions by default? options.transactions? | ||
bitcoinTransactionBuilder.createSignedTransactionsWithData({ | ||
primaryTxHex: primaryTxHex, | ||
signPrimaryTxHex: signPrimaryTxHex, | ||
data: data, | ||
id: id, | ||
fee: fee, | ||
buildStatus: buildStatus, | ||
commonBlockchain: commonBlockchain, | ||
commonWallet: commonWallet | ||
}, function (err, signedTransactions, txid) { | ||
var onSignedTransactions = function (err, signedTransactions, txid) { | ||
if (err) { } // TODO | ||
@@ -61,3 +53,17 @@ var reverseSignedTransactions = signedTransactions.reverse() | ||
commonBlockchain.Transactions.Propagate(reverseSignedTransactions[0], propagateResponse) | ||
}) | ||
} | ||
if (options.signedTransactions && options.txid) { | ||
return onSignedTransactions(false, options.signedTransactions, options.txid) | ||
} | ||
bitcoinTransactionBuilder.createSignedTransactionsWithData({ | ||
destinationAddress: destinationAddress, | ||
value: value, | ||
primaryTxHex: primaryTxHex, | ||
signPrimaryTxHex: signPrimaryTxHex, | ||
data: data, | ||
fee: fee, | ||
buildStatus: buildStatus, | ||
commonBlockchain: commonBlockchain, | ||
commonWallet: commonWallet | ||
}, onSignedTransactions) | ||
} | ||
@@ -64,0 +70,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61313
1301