-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* adds two new actions, LOCK_UTXO and UNLOCK_UTXO * lock utxos on selection * Remove UNLOCK_UTXO action - not used Add lockedUtxos to state (in state.wallet.lockedUtxos) Removes customCoinSelection (and respective file) - strategy abandoned Make coin selection avoid locked utxos Make createSendPset and createTaxiTxFromTopup return selectedUtxos Lock utxos used in successful broadcast * refactor broadcastTx call * new test * deleting experiment * remove console.log * prettier * bug fix * small code refactor * This commit creates an unconfirmed utxo from the change and adds it immediately to the utxo set for selection. This allows: - No more balances going to 0 when the transaction used all coins - Being able to use change utxo immediately without having to wait for confirmation For each change address, we hand craft the utxo with: - The txid - Given by the result of broadcastTx() - The vout - Get the transaction from the signed tx hex - transaction = Transaction.fromHex(signedTxHex) - Calculate changeOutputScript for the change address - changeOutputScript = address.toOutputScript(address, network); - Find index in transaction.outs where script = outputScript - vout = transaction.outs.findIndex(...) - The prevout - Equal to transaction.outs[vout] - The unblindData - Get the blinding private key from the Identity Interface - blindPrivKey =identities[0].getBlindingPrivateKey(prevout.script) - Unblind data - utxo = unblindOutput({ txid, vout, prevout }, blindPrivKey); After this, the utxo is added to the utxosMap on wallet state. * make a constant of minimum time utxos are locked * run unlock utxos on every successful update
- Loading branch information
Showing
17 changed files
with
296 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,22 @@ | ||
import { UnblindedOutput, unblindOutput } from 'ldk'; | ||
import { Transaction } from 'liquidjs-lib'; | ||
import { UnconfirmedOutput } from '../../domain/unconfirmed'; | ||
|
||
export const toStringOutpoint = (outpoint: { txid: string; vout: number }) => { | ||
return `${outpoint.txid}:${outpoint.vout}`; | ||
}; | ||
|
||
// for each unconfirmed output get unblindData and return utxo | ||
export const makeUnconfirmedUtxos = async ( | ||
txHex: string, | ||
unconfirmedOutputs: UnconfirmedOutput[] | ||
): Promise<UnblindedOutput[]> => { | ||
const unconfirmedUtxos: UnblindedOutput[] = []; | ||
const transaction = Transaction.fromHex(txHex); | ||
for (const { txid, vout, blindPrivKey } of unconfirmedOutputs) { | ||
const prevout = transaction.outs[vout]; | ||
const utxo = await unblindOutput({ txid, vout, prevout }, blindPrivKey); | ||
unconfirmedUtxos.push(utxo); | ||
} | ||
return unconfirmedUtxos; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export interface UnconfirmedOutput { | ||
txid: string; | ||
vout: number; | ||
blindPrivKey: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.