|
|
@ -303,89 +303,6 @@ function parseQS(query) { |
|
|
|
return out; |
|
|
|
} |
|
|
|
|
|
|
|
function createTX(outputs) { |
|
|
|
// Addresses
|
|
|
|
var addrs = [ |
|
|
|
'mzTQ66VKcybz9BD1LAqEwMFp9NrBGS82sY', |
|
|
|
'mmu9k3KzsDMEm9JxmJmZaLhovAoRKW3zr4', |
|
|
|
'myqss64GNZuWuFyg5LTaoTCyWEpKH56Fgz' |
|
|
|
]; |
|
|
|
|
|
|
|
// Private keys in WIF format (see TransactionBuilder.js for other options)
|
|
|
|
var keys = [ |
|
|
|
'cVvr5YmWVAkVeZWAawd2djwXM4QvNuwMdCw1vFQZBM1SPFrtE8W8', |
|
|
|
'cPyx1hXbe3cGQcHZbW3GNSshCYZCriidQ7afR2EBsV6ReiYhSkNF' |
|
|
|
// 'cUB9quDzq1Bj7pocenmofzNQnb1wJNZ5V3cua6pWKzNL1eQtaDqQ'
|
|
|
|
]; |
|
|
|
|
|
|
|
var unspent = [{ |
|
|
|
// http://blockexplorer.com/testnet/rawtx/1fcfe898cc2612f8b222bd3b4ac8d68bf95d43df8367b71978c184dea35bde22
|
|
|
|
'txid': '1fcfe898cc2612f8b222bd3b4ac8d68bf95d43df8367b71978c184dea35bde22', |
|
|
|
'vout': 1, |
|
|
|
'address': addrs[0], |
|
|
|
'scriptPubKey': '76a94c14cfbe41f4a518edc25af71bafc72fb61bfcfc4fcd88ac', |
|
|
|
'amount': 1.60000000, |
|
|
|
'confirmations': 9 |
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
// http://blockexplorer.com/testnet/rawtx/0624c0c794447b0d2343ae3d20382983f41b915bb115a834419e679b2b13b804
|
|
|
|
'txid': '0624c0c794447b0d2343ae3d20382983f41b915bb115a834419e679b2b13b804', |
|
|
|
'vout': 1, |
|
|
|
'address': addrs[1], |
|
|
|
'scriptPubKey': '76a94c14460376539c219c5e3274d86f16b40e806b37817688ac', |
|
|
|
'amount': 1.60000000, |
|
|
|
'confirmations': 9 |
|
|
|
} |
|
|
|
]; |
|
|
|
|
|
|
|
// define transaction output
|
|
|
|
var outs = []; |
|
|
|
outputs.forEach(function(output) { |
|
|
|
outs.push({ |
|
|
|
address: addrs[0], // dummy address
|
|
|
|
amount: 0 // dummy value
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
// set change address
|
|
|
|
var opts = { |
|
|
|
remainderOut: { |
|
|
|
address: addrs[0] |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
var tx = new TransactionBuilder(opts) |
|
|
|
.setUnspent(unspent) |
|
|
|
.setOutputs(outs) |
|
|
|
.sign(keys) |
|
|
|
.build(); |
|
|
|
|
|
|
|
outputs.forEach(function(output, i) { |
|
|
|
var value = output.get('amount'); |
|
|
|
var script = output.get('script'); |
|
|
|
var v = new Buffer(8); |
|
|
|
v[0] = (value.low >> 0) & 0xff; |
|
|
|
v[1] = (value.low >> 8) & 0xff; |
|
|
|
v[2] = (value.low >> 16) & 0xff; |
|
|
|
v[3] = (value.low >> 24) & 0xff; |
|
|
|
v[4] = (value.high >> 0) & 0xff; |
|
|
|
v[5] = (value.high >> 8) & 0xff; |
|
|
|
v[6] = (value.high >> 16) & 0xff; |
|
|
|
v[7] = (value.high >> 24) & 0xff; |
|
|
|
var s = script.buffer.slice(script.offset, script.limit); |
|
|
|
tx.outs[i].v = v; |
|
|
|
tx.outs[i].s = s; |
|
|
|
}); |
|
|
|
|
|
|
|
print(''); |
|
|
|
print('Customer created transaction:'); |
|
|
|
print(tx.getStandardizedObject()); |
|
|
|
print(''); |
|
|
|
|
|
|
|
return tx.serialize(); |
|
|
|
} |
|
|
|
|
|
|
|
function createTX(outputs) { |
|
|
|
// Addresses
|
|
|
|
var addrs = [ |
|
|
|