Browse Source

spv sendmany fix

insight-spv
pbca26 7 years ago
parent
commit
0c0db2901a
  1. 7
      routes/electrumjs/electrumServers.js
  2. 15
      routes/shepherd/electrum/createtx-multi.js

7
routes/electrumjs/electrumServers.js

@ -214,12 +214,15 @@ let electrumServers = {
],
},
ninja: { // !estimatefee
address: 'electrum.fund.ninja',
address: 'electrum1.fund.ninja',
port: 50001,
proto: 'tcp',
txfee: 10000,
abbr: 'NINJA',
serverList: 'none',
serverList: [
'electrum1.fund.ninja:50001',
'electrum2.fund.ninja:50001'
],
},
jumblr: { // !estimatefee
address: 'electrum1.cipig.net',

15
routes/shepherd/electrum/createtx-multi.js

@ -5,6 +5,8 @@ const bitcoinPos = require('bitcoinjs-lib-pos');
// not prod ready, only for voting!
// needs a fix
// TODO: spread fee across targets
// current implementation subtracts fee from the fist target out
module.exports = (shepherd) => {
shepherd.post('/electrum/createrawtx-multiout', (req, res, next) => {
if (shepherd.checkToken(req.body.token)) {
@ -131,10 +133,13 @@ module.exports = (shepherd) => {
let _change = 0;
if (outputs &&
outputs.length > 1) {
outputs.length > 1 &&
outputs.length > targets.length) {
_change = outputs[outputs.length - 1].value - fee;
}
shepherd.log(`change before adjustments ${_change}`, true);
if (!btcFee &&
_change === 0) {
outputs[0].value = outputs[0].value - fee;
@ -146,6 +151,9 @@ module.exports = (shepherd) => {
shepherd.log('init targets', true);
shepherd.log(initTargets, true);
shepherd.log('coinselect targets', true);
shepherd.log(targets, true);
if (initTargets[0].value < targets[0].value) {
targets[0].value = initTargets[0].value;
}
@ -238,13 +246,12 @@ module.exports = (shepherd) => {
res.end(JSON.stringify(successObj));
} else {
let vinSum = 0;
let voutSum = 0;
for (let i = 0; i < inputs.length; i++) {
vinSum += inputs[i].value;
}
let voutSum = 0;
for (let i = 0; i < outputs.length; i++) {
voutSum += outputs[i].value;
}
@ -272,7 +279,7 @@ module.exports = (shepherd) => {
outputAddress = outputs;
if (outputAddress.length > 1) {
if (!outputAddress[outputAddress.length - 1].address) {
outputAddress.pop();
}

Loading…
Cancel
Save