mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 18:00:17 +01:00
Merge branch 'master' into container
This commit is contained in:
commit
7db5c03790
6
blue_modules/BlueElectrum.d.ts
vendored
6
blue_modules/BlueElectrum.d.ts
vendored
@ -2,7 +2,7 @@ type Utxo = {
|
||||
height: number;
|
||||
value: number;
|
||||
address: string;
|
||||
txId: string;
|
||||
txid: string;
|
||||
vout: number;
|
||||
wif?: string;
|
||||
};
|
||||
@ -59,11 +59,11 @@ export function multiGetUtxoByAddress(addresses: string[]): Promise<Record<strin
|
||||
|
||||
// TODO: this function returns different results based on the value of `verbose`, consider splitting it into two
|
||||
export function multiGetTransactionByTxid(
|
||||
txIds: string[],
|
||||
txids: string[],
|
||||
batchsize: number = 45,
|
||||
verbose: true = true,
|
||||
): Promise<Record<string, ElectrumTransaction>>;
|
||||
export function multiGetTransactionByTxid(txIds: string[], batchsize: number, verbose: false): Promise<Record<string, string>>;
|
||||
export function multiGetTransactionByTxid(txids: string[], batchsize: number, verbose: false): Promise<Record<string, string>>;
|
||||
|
||||
export type MultiGetBalanceResponse = {
|
||||
balance: number;
|
||||
|
@ -542,7 +542,7 @@ module.exports.multiGetUtxoByAddress = async function (addresses, batchsize) {
|
||||
ret[scripthash2addr[utxos.param]] = utxos.result;
|
||||
for (const utxo of ret[scripthash2addr[utxos.param]]) {
|
||||
utxo.address = scripthash2addr[utxos.param];
|
||||
utxo.txId = utxo.tx_hash;
|
||||
utxo.txid = utxo.tx_hash;
|
||||
utxo.vout = utxo.tx_pos;
|
||||
delete utxo.tx_pos;
|
||||
delete utxo.tx_hash;
|
||||
|
@ -167,7 +167,7 @@ export class HDSegwitBech32Transaction {
|
||||
value = new BigNumber(value).multipliedBy(100000000).toNumber();
|
||||
wentIn += value;
|
||||
const address = SegwitBech32Wallet.witnessToAddress(inp.witness[inp.witness.length - 1]);
|
||||
utxos.push({ vout: inp.index, value, txId: reversedHash, address });
|
||||
utxos.push({ vout: inp.index, value, txid: reversedHash, address });
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ export class HDSegwitBech32Transaction {
|
||||
unconfirmedUtxos.push({
|
||||
vout: outp.n,
|
||||
value,
|
||||
txId: this._txid || this._txDecoded.getId(),
|
||||
txid: this._txid || this._txDecoded.getId(),
|
||||
address,
|
||||
});
|
||||
}
|
||||
|
@ -917,13 +917,11 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
||||
|
||||
// this belongs in `.getUtxo()`
|
||||
for (const u of this._utxo) {
|
||||
u.txid = u.txId;
|
||||
u.amount = u.value;
|
||||
u.wif = this._getWifForAddress(u.address);
|
||||
if (!u.confirmations && u.height) u.confirmations = BlueElectrum.estimateCurrentBlockheight() - u.height;
|
||||
}
|
||||
|
||||
this._utxo = this._utxo.sort((a, b) => Number(a.amount) - Number(b.amount));
|
||||
this._utxo = this._utxo.sort((a, b) => Number(a.value) - Number(b.value));
|
||||
// more consistent, so txhex in unit tests wont change
|
||||
}
|
||||
|
||||
@ -932,10 +930,8 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
||||
* [ { height: 0,
|
||||
* value: 666,
|
||||
* address: 'string',
|
||||
* txId: 'string',
|
||||
* vout: 1,
|
||||
* txid: 'string',
|
||||
* amount: 666,
|
||||
* wif: 'string',
|
||||
* confirmations: 0 } ]
|
||||
*
|
||||
@ -984,11 +980,9 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
||||
const value = new BigNumber(output.value).multipliedBy(100000000).toNumber();
|
||||
utxos.push({
|
||||
txid: tx.txid,
|
||||
txId: tx.txid,
|
||||
vout: output.n,
|
||||
address: String(address),
|
||||
value,
|
||||
amount: value,
|
||||
confirmations: tx.confirmations,
|
||||
wif: false,
|
||||
height: BlueElectrum.estimateCurrentBlockheight() - (tx.confirmations ?? 0),
|
||||
@ -1104,7 +1098,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param utxos {Array.<{vout: Number, value: Number, txId: String, address: String}>} List of spendable utxos
|
||||
* @param utxos {Array.<{vout: Number, value: Number, txid: String, address: String}>} List of spendable utxos
|
||||
* @param targets {Array.<{value: Number, address: String}>} Where coins are going. If theres only 1 target and that target has no value - this will send MAX to that address (respecting fee rate)
|
||||
* @param feeRate {Number} satoshi per byte
|
||||
* @param changeAddress {String} Excessive coins will go back to that address
|
||||
@ -1247,8 +1241,7 @@ export class AbstractHDElectrumWallet extends AbstractHDWallet {
|
||||
}
|
||||
|
||||
psbt.addInput({
|
||||
// @ts-ignore
|
||||
hash: input.txid || input.txId,
|
||||
hash: input.txid,
|
||||
index: input.vout,
|
||||
sequence,
|
||||
bip32Derivation: [
|
||||
|
@ -364,7 +364,7 @@ export class AbstractWallet {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param utxos {Array.<{vout: Number, value: Number, txId: String, address: String}>} List of spendable utxos
|
||||
* @param utxos {Array.<{vout: Number, value: Number, txid: String, address: String}>} List of spendable utxos
|
||||
* @param targets {Array.<{value: Number, address: String}>} Where coins are going. If theres only 1 target and that target has no value - this will send MAX to that address (respecting fee rate)
|
||||
* @param feeRate {Number} satoshi per byte
|
||||
* @param changeAddress {String} Excessive coins will go back to that address
|
||||
|
@ -139,14 +139,14 @@ export class LegacyWallet extends AbstractWallet {
|
||||
// now we need to fetch txhash for each input as required by PSBT
|
||||
if (LegacyWallet.type !== this.type) return; // but only for LEGACY single-address wallets
|
||||
const txhexes = await BlueElectrum.multiGetTransactionByTxid(
|
||||
this._utxo.map(u => u.txId),
|
||||
this._utxo.map(u => u.txid),
|
||||
50,
|
||||
false,
|
||||
);
|
||||
|
||||
const newUtxos = [];
|
||||
for (const u of this._utxo) {
|
||||
if (txhexes[u.txId]) u.txhex = txhexes[u.txId];
|
||||
if (txhexes[u.txid]) u.txhex = txhexes[u.txid];
|
||||
newUtxos.push(u);
|
||||
}
|
||||
|
||||
@ -161,10 +161,8 @@ export class LegacyWallet extends AbstractWallet {
|
||||
* [ { height: 0,
|
||||
* value: 666,
|
||||
* address: 'string',
|
||||
* txId: 'string',
|
||||
* vout: 1,
|
||||
* txid: 'string',
|
||||
* amount: 666,
|
||||
* wif: 'string',
|
||||
* confirmations: 0 } ]
|
||||
*
|
||||
@ -174,7 +172,6 @@ export class LegacyWallet extends AbstractWallet {
|
||||
getUtxo(respectFrozen = false): Utxo[] {
|
||||
let ret: Utxo[] = [];
|
||||
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);
|
||||
}
|
||||
@ -211,11 +208,9 @@ export class LegacyWallet extends AbstractWallet {
|
||||
const value = new BigNumber(output.value).multipliedBy(100000000).toNumber();
|
||||
utxos.push({
|
||||
txid: tx.txid,
|
||||
txId: tx.txid,
|
||||
vout: output.n,
|
||||
address,
|
||||
value,
|
||||
amount: value,
|
||||
confirmations: tx.confirmations,
|
||||
wif: false,
|
||||
height: BlueElectrum.estimateCurrentBlockheight() - (tx.confirmations ?? 0),
|
||||
@ -404,7 +399,7 @@ export class LegacyWallet extends AbstractWallet {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param utxos {Array.<{vout: Number, value: Number, txId: String, address: String, txhex: String, }>} List of spendable utxos
|
||||
* @param utxos {Array.<{vout: Number, value: Number, txid: String, address: String, txhex: String, }>} List of spendable utxos
|
||||
* @param targets {Array.<{value: Number, address: String}>} Where coins are going. If theres only 1 target and that target has no value - this will send MAX to that address (respecting fee rate)
|
||||
* @param feeRate {Number} satoshi per byte
|
||||
* @param changeAddress {String} Excessive coins will go back to that address
|
||||
|
@ -106,11 +106,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
headers: { 'Access-Control-Allow-Origin': '*', 'Content-Type': 'application/json' },
|
||||
});
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + (json.message ? json.message : json.error) + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -143,11 +143,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
}
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.originalResponse));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -171,11 +171,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
},
|
||||
});
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.originalResponse));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -234,11 +234,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
},
|
||||
});
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.originalResponse));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -271,11 +271,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
});
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -319,11 +319,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
});
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -348,11 +348,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
});
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -430,11 +430,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
});
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -459,11 +459,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
});
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -492,11 +492,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
});
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
if (json.code * 1 === 1 && !noRetry) {
|
||||
await this.authorize();
|
||||
return this.fetchBalance(true);
|
||||
@ -581,11 +581,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
});
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
@ -605,11 +605,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
},
|
||||
});
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.code && json.code !== 1) {
|
||||
if (json.code && json.code !== 1) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
return true;
|
||||
@ -652,11 +652,11 @@ export class LightningCustodianWallet extends LegacyWallet {
|
||||
});
|
||||
|
||||
const json = response.body;
|
||||
if (typeof json === 'undefined') {
|
||||
if (!json) {
|
||||
throw new Error('API failure: ' + response.err + ' ' + JSON.stringify(response.body));
|
||||
}
|
||||
|
||||
if (json && json.error) {
|
||||
if (json.error) {
|
||||
throw new Error('API error: ' + json.message + ' (code ' + json.code + ')');
|
||||
}
|
||||
|
||||
|
@ -770,8 +770,7 @@ export class MultisigHDWallet extends AbstractHDElectrumWallet {
|
||||
const witnessScript = p2wsh.redeem.output;
|
||||
|
||||
psbt.addInput({
|
||||
// @ts-ignore: fix me txid || txId issue
|
||||
hash: input.txid || input.txId,
|
||||
hash: input.txid,
|
||||
index: input.vout,
|
||||
sequence,
|
||||
bip32Derivation,
|
||||
|
@ -79,7 +79,7 @@ export class SegwitP2SHWallet extends LegacyWallet {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param utxos {Array.<{vout: Number, value: Number, txId: String, address: String, txhex: String, }>} List of spendable utxos
|
||||
* @param utxos {Array.<{vout: Number, value: Number, txid: String, address: String, txhex: String, }>} List of spendable utxos
|
||||
* @param targets {Array.<{value: Number, address: String}>} Where coins are going. If theres only 1 target and that target has no value - this will send MAX to that address (respecting fee rate)
|
||||
* @param feeRate {Number} satoshi per byte
|
||||
* @param changeAddress {String} Excessive coins will go back to that address
|
||||
|
@ -20,15 +20,13 @@ export type Utxo = {
|
||||
// Returned by BlueElectrum
|
||||
height: number;
|
||||
address: string;
|
||||
txId: string;
|
||||
txid: string;
|
||||
vout: number;
|
||||
value: number;
|
||||
|
||||
// Others
|
||||
txhex?: string;
|
||||
txid?: string; // TODO: same as txId, do we really need it?
|
||||
confirmations?: number;
|
||||
amount?: number; // TODO: same as value, do we really need it?
|
||||
wif?: string | false;
|
||||
};
|
||||
|
||||
@ -37,8 +35,7 @@ export type Utxo = {
|
||||
* and should be unified as soon as bullshit with txid/txId is sorted
|
||||
*/
|
||||
export type CreateTransactionUtxo = {
|
||||
txId: string;
|
||||
txid: string; // TODO: same as txId, do we really need it?
|
||||
txid: string;
|
||||
txhex: string;
|
||||
vout: number;
|
||||
value: number;
|
||||
|
@ -269,7 +269,7 @@ const TransactionsDetails = () => {
|
||||
{tx.hash && (
|
||||
<>
|
||||
<View style={styles.rowHeader}>
|
||||
<BlueText style={[styles.txId, stylesHooks.txId]}>{loc.transactions.txid}</BlueText>
|
||||
<BlueText style={styles.txid}>{loc.transactions.txid}</BlueText>
|
||||
<BlueCopyToClipboardButton stringToCopy={tx.hash} />
|
||||
</View>
|
||||
<BlueText style={styles.rowValue}>{tx.hash}</BlueText>
|
||||
@ -365,7 +365,7 @@ const styles = StyleSheet.create({
|
||||
marginBottom18: {
|
||||
marginBottom: 18,
|
||||
},
|
||||
txId: {
|
||||
txid: {
|
||||
fontSize: 16,
|
||||
fontWeight: '500',
|
||||
},
|
||||
|
@ -214,7 +214,7 @@ describe('BlueElectrum', () => {
|
||||
|
||||
assert.strictEqual(Object.keys(utxos).length, 4);
|
||||
assert.strictEqual(
|
||||
utxos.bc1qt4t9xl2gmjvxgmp5gev6m8e6s9c85979ta7jeh[0].txId,
|
||||
utxos.bc1qt4t9xl2gmjvxgmp5gev6m8e6s9c85979ta7jeh[0].txid,
|
||||
'ad00a92409d8982a1d7f877056dbed0c4337d2ebab70b30463e2802279fb936d',
|
||||
);
|
||||
assert.strictEqual(utxos.bc1qt4t9xl2gmjvxgmp5gev6m8e6s9c85979ta7jeh[0].vout, 1);
|
||||
|
@ -88,13 +88,13 @@ describe('HDSegwitBech32Transaction', () => {
|
||||
{
|
||||
vout: 1,
|
||||
value: 108150,
|
||||
txId: 'f3d7fb23248168c977e8085b6bd5381d73c85da423056a47cbf734b5665615f1',
|
||||
txid: 'f3d7fb23248168c977e8085b6bd5381d73c85da423056a47cbf734b5665615f1',
|
||||
address: 'bc1qahhgjtxexjx9t0e5pjzqwtjnxexzl6f5an38hq',
|
||||
},
|
||||
{
|
||||
vout: 0,
|
||||
value: 200000,
|
||||
txId: '89bcff166c39b3831e03257d4bcc1034dd52c18af46a3eb459e72e692a88a2d8',
|
||||
txid: '89bcff166c39b3831e03257d4bcc1034dd52c18af46a3eb459e72e692a88a2d8',
|
||||
address: 'bc1qvh44cwd2v7zld8ef9ld5rs5zafmejuslp6yd73',
|
||||
},
|
||||
]),
|
||||
@ -177,7 +177,7 @@ describe('HDSegwitBech32Transaction', () => {
|
||||
{
|
||||
vout: 0,
|
||||
value: 200000,
|
||||
txId: '2ec8a1d0686dcccffc102ba5453a28d99c8a1e5061c27b41f5c0a23b0b27e75f',
|
||||
txid: '2ec8a1d0686dcccffc102ba5453a28d99c8a1e5061c27b41f5c0a23b0b27e75f',
|
||||
address: 'bc1qvlmgrq0gtatanmas0tswrsknllvupq2g844ss2',
|
||||
},
|
||||
]),
|
||||
|
@ -79,7 +79,7 @@ describe('Bech32 Segwit HD (BIP84)', () => {
|
||||
await hd.fetchUtxo();
|
||||
const utxo = hd.getUtxo();
|
||||
assert.strictEqual(utxo.length, 4);
|
||||
assert.ok(utxo[0].txId);
|
||||
assert.ok(utxo[0].txid);
|
||||
assert.ok(utxo[0].vout === 0 || utxo[0].vout === 1);
|
||||
assert.ok(utxo[0].value);
|
||||
assert.ok(utxo[0].address);
|
||||
|
@ -62,7 +62,7 @@ it('HD (BIP49) can create TX', async () => {
|
||||
assert.ok(typeof hd._utxo[0].confirmations === 'number');
|
||||
assert.ok(hd._utxo[0].txid);
|
||||
assert.ok(hd._utxo[0].vout !== undefined);
|
||||
assert.ok(hd._utxo[0].amount);
|
||||
assert.ok(hd._utxo[0].value);
|
||||
assert.ok(hd._utxo[0].address);
|
||||
assert.ok(hd._utxo[0].wif);
|
||||
|
||||
@ -181,7 +181,7 @@ it('Segwit HD (BIP49) can fetch balance with many used addresses in hierarchy',
|
||||
assert.ok(hd._utxo.length > 0);
|
||||
assert.ok(hd._utxo[0].txid);
|
||||
assert.ok(hd._utxo[0].vout === 0);
|
||||
assert.ok(hd._utxo[0].amount);
|
||||
assert.ok(hd._utxo[0].value);
|
||||
|
||||
await hd.fetchTransactions();
|
||||
assert.strictEqual(hd.getTransactions().length, 107);
|
||||
|
@ -66,7 +66,6 @@ describe('LegacyWallet', function () {
|
||||
assert.strictEqual(tx.vout, 0);
|
||||
assert.strictEqual(tx.address, '3GCvDBAktgQQtsbN6x5DYiQCMmgZ9Yk8BK');
|
||||
assert.strictEqual(tx.value, 51432);
|
||||
assert.strictEqual(tx.value, tx.amount);
|
||||
assert.ok(tx.confirmations! > 0);
|
||||
}
|
||||
});
|
||||
|
@ -138,7 +138,7 @@ describe('AbstractHDElectrumWallet.cosign', () => {
|
||||
],
|
||||
witnessUtxo: {
|
||||
script: p2sh.output,
|
||||
value: input.amount || input.value,
|
||||
value: input.value,
|
||||
},
|
||||
redeemScript: p2wpkh.output,
|
||||
});
|
||||
@ -223,10 +223,8 @@ describe('AbstractHDElectrumWallet.cosign', () => {
|
||||
height: 707112,
|
||||
value: 10000,
|
||||
address: 'bc1q79hsqzg9q6d36ftyncwv2drg7pyt66pamghn9n',
|
||||
txId: 'e598c705bef463e2e12d7bebc15e3cf0a34477679c3c21de9693987c6de8f15e',
|
||||
vout: 0,
|
||||
txid: 'e598c705bef463e2e12d7bebc15e3cf0a34477679c3c21de9693987c6de8f15e',
|
||||
amount: 10000,
|
||||
wif: false,
|
||||
confirmations: 1,
|
||||
},
|
||||
|
@ -54,10 +54,8 @@ describe('Legacy HD (BIP44)', () => {
|
||||
height: 554830,
|
||||
value: 10000,
|
||||
address: '186FBQmCV5W1xY7ywaWtTZPAQNciVN8Por',
|
||||
txId: '4f65c8cb159585c00d4deba9c5b36a2bcdfb1399a561114dcf6f2d0c1174bc5f',
|
||||
vout: 0,
|
||||
txid: '4f65c8cb159585c00d4deba9c5b36a2bcdfb1399a561114dcf6f2d0c1174bc5f',
|
||||
amount: 10000,
|
||||
wif: 'Kz6kLhdyDfSbKuVH25XVqBRztjmFe8X22Xe1hnFzEv79gJNMkTAH',
|
||||
confirmations: 1,
|
||||
txhex:
|
||||
@ -67,10 +65,8 @@ describe('Legacy HD (BIP44)', () => {
|
||||
height: 554830,
|
||||
value: 20000,
|
||||
address: '1J9zoJz5LsAJ361SQHYnLTWg46Tc2AXUCj',
|
||||
txId: '4f65c8cb159585c00d4deba9c5b36a2bcdfb1399a561114dcf6f2d0c1174bc5f',
|
||||
vout: 1,
|
||||
txid: '4f65c8cb159585c00d4deba9c5b36a2bcdfb1399a561114dcf6f2d0c1174bc5f',
|
||||
amount: 20000,
|
||||
wif: 'L4ojevRtK81A8Kof3qyLS2M7HvsVDbUDENNhJqU4vf79w9yGnQLb',
|
||||
confirmations: 1,
|
||||
txhex:
|
||||
@ -80,10 +76,8 @@ describe('Legacy HD (BIP44)', () => {
|
||||
height: 554830,
|
||||
value: 30000,
|
||||
address: '186FBQmCV5W1xY7ywaWtTZPAQNciVN8Por',
|
||||
txId: '4f65c8cb159585c00d4deba9c5b36a2bcdfb1399a561114dcf6f2d0c1174bc5f',
|
||||
vout: 2,
|
||||
txid: '4f65c8cb159585c00d4deba9c5b36a2bcdfb1399a561114dcf6f2d0c1174bc5f',
|
||||
amount: 30000,
|
||||
wif: 'Kz6kLhdyDfSbKuVH25XVqBRztjmFe8X22Xe1hnFzEv79gJNMkTAH',
|
||||
confirmations: 1,
|
||||
txhex:
|
||||
@ -93,10 +87,8 @@ describe('Legacy HD (BIP44)', () => {
|
||||
height: 554830,
|
||||
value: 40000,
|
||||
address: '1J9zoJz5LsAJ361SQHYnLTWg46Tc2AXUCj',
|
||||
txId: '4f65c8cb159585c00d4deba9c5b36a2bcdfb1399a561114dcf6f2d0c1174bc5f',
|
||||
vout: 3,
|
||||
txid: '4f65c8cb159585c00d4deba9c5b36a2bcdfb1399a561114dcf6f2d0c1174bc5f',
|
||||
amount: 40000,
|
||||
wif: 'L4ojevRtK81A8Kof3qyLS2M7HvsVDbUDENNhJqU4vf79w9yGnQLb',
|
||||
confirmations: 1,
|
||||
txhex:
|
||||
|
@ -224,12 +224,10 @@ describe('Bech32 Segwit HD (BIP84)', () => {
|
||||
|
||||
const utxo = [
|
||||
{
|
||||
value: 69909,
|
||||
address: 'bc1q063ctu6jhe5k4v8ka99qac8rcm2tzjjnuktyrl',
|
||||
txId: '8b0ab2c7196312e021e0d3dc73f801693826428782970763df6134457bd2ec20',
|
||||
vout: 0,
|
||||
txid: '8b0ab2c7196312e021e0d3dc73f801693826428782970763df6134457bd2ec20',
|
||||
amount: 69909,
|
||||
value: 69909,
|
||||
wif: '-',
|
||||
},
|
||||
];
|
||||
|
@ -68,10 +68,8 @@ describe('multisig-wallet (p2sh)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: '3J5xQcgBqoykSHhmDJLYp87SgVSNhYrvnz',
|
||||
txId: '630a227c0b4ca30bc98689d40d31e0407fcc5d61730ce1fa548b26630efddeec',
|
||||
vout: 0,
|
||||
txid: '630a227c0b4ca30bc98689d40d31e0407fcc5d61730ce1fa548b26630efddeec',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
confirmations: 666,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
@ -161,10 +159,8 @@ describe('multisig-wallet (p2sh)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: '3J5xQcgBqoykSHhmDJLYp87SgVSNhYrvnz',
|
||||
txId: '630a227c0b4ca30bc98689d40d31e0407fcc5d61730ce1fa548b26630efddeec',
|
||||
vout: 0,
|
||||
txid: '630a227c0b4ca30bc98689d40d31e0407fcc5d61730ce1fa548b26630efddeec',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
confirmations: 666,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
@ -242,10 +238,8 @@ describe('multisig-wallet (p2sh)', () => {
|
||||
height: 666,
|
||||
value: 87740,
|
||||
address: '3PmqRLiPnBXhdYGN6mAHChXLPvw8wb3Yt8',
|
||||
txId: '33eaa5193c71519deb968852c9938824d14504a785479a051ea07cc68400ee23',
|
||||
vout: 1,
|
||||
txid: '33eaa5193c71519deb968852c9938824d14504a785479a051ea07cc68400ee23',
|
||||
amount: 87740,
|
||||
wif: false,
|
||||
confirmations: 666,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
@ -310,10 +304,8 @@ describe('multisig-wallet (p2sh)', () => {
|
||||
height: 666,
|
||||
value: 87740,
|
||||
address: '3PmqRLiPnBXhdYGN6mAHChXLPvw8wb3Yt8',
|
||||
txId: '33eaa5193c71519deb968852c9938824d14504a785479a051ea07cc68400ee23',
|
||||
vout: 1,
|
||||
txid: '33eaa5193c71519deb968852c9938824d14504a785479a051ea07cc68400ee23',
|
||||
amount: 87740,
|
||||
wif: false,
|
||||
confirmations: 666,
|
||||
txhex:
|
||||
@ -392,10 +384,8 @@ describe('multisig-wallet (wrapped segwit)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: '38xA38nfy649CC2JjjZj1CYAhtrcRc67dk',
|
||||
txId: 'e36f630517f5b094a9287e73bdb443792088255c50d74414c7f25bd7fbdcf18e',
|
||||
vout: 0,
|
||||
txid: 'e36f630517f5b094a9287e73bdb443792088255c50d74414c7f25bd7fbdcf18e',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
confirmations: 666,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
@ -460,10 +450,8 @@ describe('multisig-wallet (wrapped segwit)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: '38xA38nfy649CC2JjjZj1CYAhtrcRc67dk',
|
||||
txId: 'e36f630517f5b094a9287e73bdb443792088255c50d74414c7f25bd7fbdcf18e',
|
||||
vout: 0,
|
||||
txid: 'e36f630517f5b094a9287e73bdb443792088255c50d74414c7f25bd7fbdcf18e',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
confirmations: 666,
|
||||
@ -536,10 +524,8 @@ describe('multisig-wallet (wrapped segwit)', () => {
|
||||
height: 666,
|
||||
value: 87740,
|
||||
address: '3PU8J9pdiKAMsLnrhyrG7RZ4LZiTURQp5r',
|
||||
txId: '31d614bc1d6fcbcb273f585f87d2e619784920f8cb0c2396e4a03f1bb86fed64',
|
||||
vout: 1,
|
||||
txid: '31d614bc1d6fcbcb273f585f87d2e619784920f8cb0c2396e4a03f1bb86fed64',
|
||||
amount: 87740,
|
||||
wif: false,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
confirmations: 666,
|
||||
@ -822,10 +808,8 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: 'bc1qxzrzh4caw7e3genwtldtxntzj0ktfl7mhf2lh4fj8h7hnkvtvc4salvp85',
|
||||
txId: '666b1f2ee25dfd92377bb66a8db2badf45625a59e93f5a89836e178f9f5ed396',
|
||||
vout: 0,
|
||||
txid: '666b1f2ee25dfd92377bb66a8db2badf45625a59e93f5a89836e178f9f5ed396',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
confirmations: 0,
|
||||
@ -974,10 +958,8 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: 'bc1qxzrzh4caw7e3genwtldtxntzj0ktfl7mhf2lh4fj8h7hnkvtvc4salvp85',
|
||||
txId: '666b1f2ee25dfd92377bb66a8db2badf45625a59e93f5a89836e178f9f5ed396',
|
||||
vout: 0,
|
||||
txid: '666b1f2ee25dfd92377bb66a8db2badf45625a59e93f5a89836e178f9f5ed396',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
confirmations: 0,
|
||||
@ -1046,10 +1028,8 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: 'bc1qxzrzh4caw7e3genwtldtxntzj0ktfl7mhf2lh4fj8h7hnkvtvc4salvp85',
|
||||
txId: '666b1f2ee25dfd92377bb66a8db2badf45625a59e93f5a89836e178f9f5ed396',
|
||||
vout: 0,
|
||||
txid: '666b1f2ee25dfd92377bb66a8db2badf45625a59e93f5a89836e178f9f5ed396',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
confirmations: 0,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
@ -1256,10 +1236,8 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: 'bc1qxzrzh4caw7e3genwtldtxntzj0ktfl7mhf2lh4fj8h7hnkvtvc4salvp85',
|
||||
txId: '666b1f2ee25dfd92377bb66a8db2badf45625a59e93f5a89836e178f9f5ed396',
|
||||
vout: 0,
|
||||
txid: '666b1f2ee25dfd92377bb66a8db2badf45625a59e93f5a89836e178f9f5ed396',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
confirmations: 0,
|
||||
txhex:
|
||||
@ -1416,10 +1394,8 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: 'bc1q2mkhkvx9l7aqksvyf0dwd2x4yn8qx2w3sythjltdkjw70r8hsves2evfg6',
|
||||
txId: 'c097161e8ae3b12ae2c90da95ade1185e368269a861ea9a8da023714d6fea31e',
|
||||
vout: 0,
|
||||
txid: 'c097161e8ae3b12ae2c90da95ade1185e368269a861ea9a8da023714d6fea31e',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
script: { length: 107 }, // incorrect value so old tests pass. in reality its calculated on the fly
|
||||
confirmations: 666,
|
||||
@ -1466,9 +1442,7 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
const utxos = [
|
||||
{
|
||||
address: 'bc1qmpyrvv6fmkv494r9qk9nllyuyngtqj62fywcl2xzessgwf9qgrssxff69u',
|
||||
amount: 68419,
|
||||
height: 0,
|
||||
txId: '2d40b967bb3a4ecd8517843d01042b0dd4227192acbe0e1ad1f1cf144a1ec0c9',
|
||||
txhex:
|
||||
'02000000000101d7bf498a92b19bab8a58260efedd7e6cd3b7713ff1e9d2603ff9f06a64f66291000000001716001440512e04b685a0cd66a03bea0896c27000c828dcffffffff01430b010000000000220020d848363349dd9952d465058b3ffc9c24d0b04b4a491d8fa8c2cc208724a040e10247304402201ad742ffee74e5ae4b3867d9818b8ad6505ca5239280138f9da3f93e4c27ee0802202918fa6034485077596bf64501ae6954371e91d250ee98f5a3c5889d4dee923e012103a681da832358050bd9b197aaa55d921f1447025b999eadb018aa67c5b8f64a0900000000',
|
||||
txid: '2d40b967bb3a4ecd8517843d01042b0dd4227192acbe0e1ad1f1cf144a1ec0c9',
|
||||
@ -1858,10 +1832,8 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
height: 662352,
|
||||
value: 100000,
|
||||
address: 'bc1qlkh0zgq5ypcdfs9rdvrucra96c5gmjgaufm0au8cglkkrah29nesrkvewg',
|
||||
txId: 'e112e3b109aff5fe76d4fde90bd3c2df58bfb250280a4404421fff42d6801fd2',
|
||||
vout: 0,
|
||||
txid: 'e112e3b109aff5fe76d4fde90bd3c2df58bfb250280a4404421fff42d6801fd2',
|
||||
amount: 100000,
|
||||
wif: false,
|
||||
confirmations: 1,
|
||||
txhex:
|
||||
@ -1907,10 +1879,8 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
const utxos = [
|
||||
{
|
||||
address: 'bc1qzwt595g0q0xauxzr4h56kw4zavfrnq3r4zkx42relm8rvwuuxyvsqndmgl',
|
||||
amount: 2120,
|
||||
confirmations: 33,
|
||||
height: 668483,
|
||||
txId: '43b2ac418539b61610c3ae2e216052d634b9b20fcece05940b5662fe5cf3f3b5',
|
||||
txhex:
|
||||
'020000000001019e590dee7124728b988e32c1daad3a550663327b3478c4f9ee15eeaf740b898f0100000017160014018958ab9e2b29b7313a39c1a62189affeac94a8ffffffff014808000000000000220020139742d10f03cdde1843ade9ab3aa2eb12398223a8ac6aa879fece363b9c311902483045022100f431ad4d213265531f600ebf242cabd3adcb7b5c27464ad080a34ce4fb4a5e5702206fad42768d29ee1121e19dc4489366d0c02a412e9d60431cac59d49642868c7b0121037a24a1d8a4e86946e89478f352bda9d6b40843e01b86af5c94b99634cbb0c6b200000000',
|
||||
txid: '43b2ac418539b61610c3ae2e216052d634b9b20fcece05940b5662fe5cf3f3b5',
|
||||
@ -1920,10 +1890,8 @@ describe('multisig-wallet (native segwit)', () => {
|
||||
},
|
||||
{
|
||||
address: 'bc1qn0j7y5hau6s8tdcpnxyyumck256lfet78ehpxdkytv5nt570dr4qxl9s3p',
|
||||
amount: 10000,
|
||||
confirmations: 1,
|
||||
height: 668515,
|
||||
txId: '3a2753147121c2ab312a419f0788cb534232d3c0bd4838de718487aca495ac7a',
|
||||
txhex:
|
||||
'02000000000101a1fba4a09a1a7ed090c64f15024de4b9008b6ec4ee5e336f0f0fc43f78022dfa01000000171600142f78bf055b26feb8f2f6b3caa5956b991c507e49ffffffff0210270000000000002200209be5e252fde6a075b70199884e6f165535f4e57e3e6e1336c45b2935d3cf68ea9a8705000000000017a91484d55f28fc28676c5f195ce649851428ec5010a3870248304502210098a970398bc40a34423d5661ecc499240bb0edb6e6bea74a752269f92e588b1b022031fcdf66c4ed8378f352a5a096c438e7a8c1415c47c119a4c69ef787e1cdf5d9012102ade0a25d66406f67dc3e4a6c8bedd989dd3ceed7a623fb4c2839a84b5262ca0900000000',
|
||||
txid: '3a2753147121c2ab312a419f0788cb534232d3c0bd4838de718487aca495ac7a',
|
||||
|
@ -9,10 +9,8 @@ const utxos = [
|
||||
height: 666,
|
||||
value: 100000,
|
||||
address: 'bc1q2j76s63hx6ue4hfklhtkny4fx822kzw2ycyn5r',
|
||||
txId: '8e8c982479c18b4331748c97c424891a4a474a61e5fdf6ac442c47cd44f13614',
|
||||
vout: 0,
|
||||
txid: '8e8c982479c18b4331748c97c424891a4a474a61e5fdf6ac442c47cd44f13614',
|
||||
amount: 100000,
|
||||
wif: '',
|
||||
confirmations: 666,
|
||||
},
|
||||
|
@ -126,18 +126,13 @@ describe('Watch only wallet', () => {
|
||||
height: 596736,
|
||||
value: 20000,
|
||||
address: 'bc1qhu8jqyzfazgatpctqn44xr7pdd3mdx6qy2r6xa',
|
||||
txId: '7f3b9e032a84413d7a5027b0d020f8acf80ad28f68b5bce8fa8ac357248c5b80',
|
||||
txid: '7f3b9e032a84413d7a5027b0d020f8acf80ad28f68b5bce8fa8ac357248c5b80',
|
||||
vout: 0,
|
||||
},
|
||||
];
|
||||
// hardcoding utxo so we wont have to call w.fetchUtxo() and w.getUtxo()
|
||||
|
||||
const { psbt } = await w.createTransaction(
|
||||
utxos,
|
||||
[{ address: 'bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu', value: 5000 }],
|
||||
1,
|
||||
changeAddress,
|
||||
);
|
||||
const { psbt } = w.createTransaction(utxos, [{ address: 'bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu', value: 5000 }], 1, changeAddress);
|
||||
|
||||
assert.strictEqual(
|
||||
psbt.toBase64(),
|
||||
@ -164,10 +159,8 @@ describe('Watch only wallet', () => {
|
||||
height: 618811,
|
||||
value: 66600,
|
||||
address: 'bc1qzqjwye4musmz56cg44ttnchj49zueh9yr0qsxt',
|
||||
txId: '5df595dc09ee7a5c245b34ea519288137ffee731629c4ff322a6de4f72c06222',
|
||||
vout: 0,
|
||||
txid: '5df595dc09ee7a5c245b34ea519288137ffee731629c4ff322a6de4f72c06222',
|
||||
amount: 66600,
|
||||
wif: false,
|
||||
confirmations: 1,
|
||||
},
|
||||
@ -204,10 +197,8 @@ describe('Watch only wallet', () => {
|
||||
height: 618811,
|
||||
value: 66600,
|
||||
address: 'bc1qzqjwye4musmz56cg44ttnchj49zueh9yr0qsxt',
|
||||
txId: '5df595dc09ee7a5c245b34ea519288137ffee731629c4ff322a6de4f72c06222',
|
||||
vout: 0,
|
||||
txid: '5df595dc09ee7a5c245b34ea519288137ffee731629c4ff322a6de4f72c06222',
|
||||
amount: 66600,
|
||||
wif: false,
|
||||
confirmations: 1,
|
||||
},
|
||||
@ -418,10 +409,8 @@ describe('Watch only wallet', () => {
|
||||
height: 557538,
|
||||
value: 51432,
|
||||
address: '3GCvDBAktgQQtsbN6x5DYiQCMmgZ9Yk8BK',
|
||||
txId: 'b2ac59bc282083498d1e87805d89bef9d3f3bc216c1d2c4dfaa2e2911b547100',
|
||||
vout: 0,
|
||||
txid: 'b2ac59bc282083498d1e87805d89bef9d3f3bc216c1d2c4dfaa2e2911b547100',
|
||||
amount: 51432,
|
||||
wif: false,
|
||||
confirmations: 132402,
|
||||
},
|
||||
@ -429,12 +418,7 @@ describe('Watch only wallet', () => {
|
||||
|
||||
const changeAddress = '3DrZBgntD8kBBbuKLJtPVAeGT75BMC7NxU';
|
||||
|
||||
const { psbt } = await w.createTransaction(
|
||||
utxos,
|
||||
[{ address: 'bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu', value: 5000 }],
|
||||
1,
|
||||
changeAddress,
|
||||
);
|
||||
const { psbt } = w.createTransaction(utxos, [{ address: 'bc1qcr8te4kr609gcawutmrza0j4xv80jy8z306fyu', value: 5000 }], 1, changeAddress);
|
||||
|
||||
assert.strictEqual(
|
||||
psbt.data.outputs[1].bip32Derivation[0].pubkey.toString('hex'),
|
||||
|
4
typings/coinselect.d.ts
vendored
4
typings/coinselect.d.ts
vendored
@ -10,7 +10,7 @@ declare module 'coinselect' {
|
||||
export type CoinSelectUtxo = {
|
||||
vout: number;
|
||||
value: number;
|
||||
txId: string;
|
||||
txid: string;
|
||||
address?: string;
|
||||
wif?: string;
|
||||
txhex?: string;
|
||||
@ -52,7 +52,7 @@ declare module 'coinselect/split' {
|
||||
type Utxo = {
|
||||
vout: number;
|
||||
value: number;
|
||||
txId: string;
|
||||
txid: string;
|
||||
};
|
||||
|
||||
export default function coinSelectSplit<U extends Utxo>(
|
||||
|
Loading…
Reference in New Issue
Block a user