-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wallet.fund() messes up existing inputs #639
Changes from 1 commit
961645a
c9d0d8d
3506db5
76b06e2
43bf26c
edc1f25
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,6 @@ const {types} = rules; | |
const {Mnemonic} = HD; | ||
const {BufferSet} = require('buffer-map'); | ||
const Coin = require('../primitives/coin'); | ||
const Outpoint = require('../primitives/outpoint'); | ||
|
||
/* | ||
* Constants | ||
|
@@ -1839,7 +1838,7 @@ class Wallet extends EventEmitter { | |
output.covenant.pushHash(nameHash); | ||
output.covenant.pushU32(height); | ||
output.covenant.pushHash(nonce); | ||
reveal.addOutpoint(Outpoint.fromTX(bid, bidOuputIndex)); | ||
reveal.addCoin(bidCoin); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are technically not necessary because the Coin would attempted to be added to CoinView if it's already not there. But this is cleaner. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I think now with this logic: edc1f25 using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. addCoin will still stay an optimization if we use my suggestion. |
||
reveal.outputs.push(output); | ||
|
||
await this.fill(reveal, { ...options, coins: coins }); | ||
|
@@ -1926,7 +1925,7 @@ class Wallet extends EventEmitter { | |
output.covenant.pushU32(ns.height); | ||
output.covenant.pushHash(nonce); | ||
|
||
mtx.addOutpoint(prevout); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
} | ||
|
||
|
@@ -2051,7 +2050,7 @@ class Wallet extends EventEmitter { | |
output.covenant.pushU32(ns.height); | ||
output.covenant.pushHash(nonce); | ||
|
||
mtx.addOutpoint(prevout); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
} | ||
|
||
|
@@ -2176,7 +2175,7 @@ class Wallet extends EventEmitter { | |
if (coin.height < ns.height) | ||
continue; | ||
|
||
mtx.addOutpoint(prevout); | ||
mtx.addCoin(coin); | ||
|
||
const output = new Output(); | ||
output.address = coin.address; | ||
|
@@ -2298,7 +2297,7 @@ class Wallet extends EventEmitter { | |
if (coin.height < ns.height) | ||
continue; | ||
|
||
mtx.addOutpoint(prevout); | ||
mtx.addCoin(coin); | ||
|
||
const output = new Output(); | ||
output.address = coin.address; | ||
|
@@ -2444,7 +2443,7 @@ class Wallet extends EventEmitter { | |
output.covenant.pushHash(await this.wdb.getRenewalBlock()); | ||
|
||
const mtx = new MTX(); | ||
mtx.addOutpoint(ns.owner); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
|
||
return mtx; | ||
|
@@ -2524,7 +2523,7 @@ class Wallet extends EventEmitter { | |
output.covenant.push(raw); | ||
|
||
const mtx = new MTX(); | ||
mtx.addOutpoint(ns.owner); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
|
||
return mtx; | ||
|
@@ -2663,7 +2662,7 @@ class Wallet extends EventEmitter { | |
output.covenant.pushHash(await this.wdb.getRenewalBlock()); | ||
|
||
const mtx = new MTX(); | ||
mtx.addOutpoint(ns.owner); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
|
||
return mtx; | ||
|
@@ -2797,7 +2796,7 @@ class Wallet extends EventEmitter { | |
output.covenant.push(address.hash); | ||
|
||
const mtx = new MTX(); | ||
mtx.addOutpoint(ns.owner); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
|
||
return mtx; | ||
|
@@ -2933,7 +2932,7 @@ class Wallet extends EventEmitter { | |
output.covenant.push(EMPTY); | ||
|
||
const mtx = new MTX(); | ||
mtx.addOutpoint(ns.owner); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
|
||
return mtx; | ||
|
@@ -3077,7 +3076,7 @@ class Wallet extends EventEmitter { | |
output.covenant.pushHash(await this.wdb.getRenewalBlock()); | ||
|
||
const mtx = new MTX(); | ||
mtx.addOutpoint(ns.owner); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
|
||
return mtx; | ||
|
@@ -3208,7 +3207,7 @@ class Wallet extends EventEmitter { | |
output.covenant.pushU32(ns.height); | ||
|
||
const mtx = new MTX(); | ||
mtx.addOutpoint(ns.owner); | ||
mtx.addCoin(coin); | ||
mtx.outputs.push(output); | ||
|
||
return mtx; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here instead of pushing blindly, we check if
view
has it, if it already has it we don't push this. Everything else can remain same.