mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-26 08:55:56 +01:00
ADD: getUtxo frozen argument
This commit is contained in:
parent
8c484ffecb
commit
3bcc60d5bc
4 changed files with 20 additions and 13 deletions
|
@ -716,9 +716,18 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
|||
*
|
||||
* @returns {[]}
|
||||
*/
|
||||
getUtxo() {
|
||||
if (this._utxo.length === 0) return this.getDerivedUtxoFromOurTransaction(); // oy vey, no stored utxo. lets attempt to derive it from stored transactions
|
||||
return this._utxo;
|
||||
getUtxo({ frozen = false } = {}) {
|
||||
let ret = [];
|
||||
|
||||
if (this._utxo.length === 0) {
|
||||
ret = this.getDerivedUtxoFromOurTransaction(); // oy vey, no stored utxo. lets attempt to derive it from stored transactions
|
||||
} else {
|
||||
ret = this._utxo;
|
||||
}
|
||||
if (!frozen && this.frozenUtxo) {
|
||||
ret = ret.filter(({ txId, vout }) => !this.frozenUtxo.some(i => txId === i.txid && vout === i.vout));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
getDerivedUtxoFromOurTransaction(returnSpentUtxoAsWell = false) {
|
||||
|
|
|
@ -139,14 +139,14 @@ export class LegacyWallet extends AbstractWallet {
|
|||
}
|
||||
}
|
||||
|
||||
getUtxo({ frozen = false }) {
|
||||
getUtxo({ frozen = false } = {}) {
|
||||
let ret = [];
|
||||
for (const u of this.utxo) {
|
||||
if (u.txId) u.txid = u.txId;
|
||||
if (!u.confirmations && u.height) u.confirmations = BlueElectrum.estimateCurrentBlockheight() - u.height;
|
||||
ret.push(u);
|
||||
}
|
||||
if (frozen && this.frozenUtxo) {
|
||||
if (!frozen && this.frozenUtxo) {
|
||||
ret = ret.filter(({ txId, vout }) => !this.frozenUtxo.some(i => txId === i.txid && vout === i.vout));
|
||||
}
|
||||
return ret;
|
||||
|
|
|
@ -150,8 +150,8 @@ export class WatchOnlyWallet extends LegacyWallet {
|
|||
throw new Error('Not initialized');
|
||||
}
|
||||
|
||||
getUtxo() {
|
||||
if (this._hdWalletInstance) return this._hdWalletInstance.getUtxo();
|
||||
getUtxo(...args) {
|
||||
if (this._hdWalletInstance) return this._hdWalletInstance.getUtxo(...args);
|
||||
throw new Error('Not initialized');
|
||||
}
|
||||
|
||||
|
|
|
@ -72,8 +72,6 @@ const CoinControl = () => {
|
|||
const frozenUtxo = wallet.getFrozenUtxo();
|
||||
const switchValue = output && frozenUtxo.some(({ txid, vout }) => output.txid === txid && output.vout === vout);
|
||||
|
||||
console.info('frozenUtxo', frozenUtxo);
|
||||
|
||||
const handleChoose = item => setOutput(item);
|
||||
const onFreeze = async ({ txid, vout }, value) => {
|
||||
if (value) {
|
||||
|
@ -84,11 +82,11 @@ const CoinControl = () => {
|
|||
await BlueApp.saveToDisk();
|
||||
setReRender(i => !i);
|
||||
};
|
||||
const renderItem = ({ item }) => (
|
||||
const renderItem = p => (
|
||||
<Output
|
||||
item={item}
|
||||
frozen={frozenUtxo.some(({ txid, vout }) => item.txid === txid && item.vout === vout)}
|
||||
onPress={() => handleChoose(item)}
|
||||
item={p.item}
|
||||
frozen={frozenUtxo.some(({ txid, vout }) => p.item.txid === txid && p.item.vout === vout)}
|
||||
onPress={() => handleChoose(p.item)}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue