@ledgerhq/live-common 21.14.0 → 21.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/__tests__/derivation.js +1 -1
- package/lib/__tests__/derivation.js.map +1 -1
- package/lib/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.js +2 -2
- package/lib/families/bitcoin/wallet-btc/crypto/base.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/base.js +1 -0
- package/lib/families/bitcoin/wallet-btc/crypto/base.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/bitcoincash.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zec.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js +1 -1
- package/lib/families/bitcoin/wallet-btc/crypto/zen.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/utils.d.ts +1 -1
- package/lib/families/bitcoin/wallet-btc/utils.d.ts.map +1 -1
- package/lib/families/bitcoin/wallet-btc/utils.js +10 -6
- package/lib/families/bitcoin/wallet-btc/utils.js.map +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.js +1 -1
- package/lib/families/bitcoin/wallet-btc/wallet.js.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/all.libcore.ts.snap +49100 -49100
- package/src/__tests__/derivation.ts +1 -1
- package/src/__tests__/families/bitcoin/wallet-btc/wallet.integration.test.ts +2 -2
- package/src/families/bitcoin/wallet-btc/crypto/base.ts +1 -0
- package/src/families/bitcoin/wallet-btc/crypto/bitcoincash.ts +1 -1
- package/src/families/bitcoin/wallet-btc/crypto/zec.ts +1 -1
- package/src/families/bitcoin/wallet-btc/crypto/zen.ts +1 -1
- package/src/families/bitcoin/wallet-btc/utils.ts +10 -6
- package/src/families/bitcoin/wallet-btc/wallet.ts +1 -1
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
describe("derivation", () => {
|
|
7
7
|
test("getPreferredNewAccountScheme should return a list of schemes for a given currency", () => {
|
|
8
8
|
const testData = [
|
|
9
|
-
["bitcoin", ["native_segwit", "segwit", ""]],
|
|
9
|
+
["bitcoin", ["native_segwit", "taproot", "segwit", ""]],
|
|
10
10
|
["ethereum", null],
|
|
11
11
|
["cosmos", null],
|
|
12
12
|
["litecoin", ["native_segwit", "segwit", ""]],
|
|
@@ -63,7 +63,7 @@ describe("testing wallet", () => {
|
|
|
63
63
|
fromAccount: account,
|
|
64
64
|
txInfo,
|
|
65
65
|
});
|
|
66
|
-
expect(tx).toEqual("
|
|
66
|
+
expect(tx).toEqual("d6154bba4915d07453bb09d4fa02d62e975b4475");
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it("should allow to build a transaction splitting outputs", async () => {
|
|
@@ -87,7 +87,7 @@ describe("testing wallet", () => {
|
|
|
87
87
|
fromAccount: account,
|
|
88
88
|
txInfo,
|
|
89
89
|
});
|
|
90
|
-
expect(tx).toEqual("
|
|
90
|
+
expect(tx).toEqual("d922a70d6a66b96cdaba4565270a21f97eb23a6d");
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
it("should throw during sync if there is an error in explorer", async () => {
|
|
@@ -83,12 +83,12 @@ export function byteSize(count: number) {
|
|
|
83
83
|
return 1;
|
|
84
84
|
}
|
|
85
85
|
if (count <= 0xffff) {
|
|
86
|
-
return
|
|
86
|
+
return 3;
|
|
87
87
|
}
|
|
88
88
|
if (count <= 0xffffffff) {
|
|
89
|
-
return
|
|
89
|
+
return 5;
|
|
90
90
|
}
|
|
91
|
-
return
|
|
91
|
+
return 9;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// refer to https://github.com/LedgerHQ/lib-ledger-core/blob/fc9d762b83fc2b269d072b662065747a64ab2816/core/src/wallet/bitcoin/api_impl/BitcoinLikeTransactionApi.cpp#L217
|
|
@@ -106,10 +106,14 @@ export function estimateTxSize(
|
|
|
106
106
|
fixedSize += byteSize(inputCount); // Number of inputs
|
|
107
107
|
fixedSize += byteSize(outputCount); // Number of outputs
|
|
108
108
|
fixedSize += 4; // Timelock
|
|
109
|
+
if (derivationMode !== DerivationModes.LEGACY) {
|
|
110
|
+
fixedSize += 0.5; // Segwit marker & segwit flag
|
|
111
|
+
}
|
|
109
112
|
// refer to https://medium.com/coinmonks/on-bitcoin-transaction-sizes-part-2-9445373d17f4
|
|
110
113
|
// and https://bitcoin.stackexchange.com/questions/96017/what-are-the-sizes-of-single-sig-and-2-of-3-multisig-taproot-inputs
|
|
114
|
+
// and https://bitcoinops.org/en/tools/calc-size/
|
|
111
115
|
if (derivationMode === DerivationModes.TAPROOT) {
|
|
112
|
-
txSize = fixedSize + 57.
|
|
116
|
+
txSize = fixedSize + 57.75 * inputCount + 43 * outputCount;
|
|
113
117
|
return Math.ceil(txSize);
|
|
114
118
|
}
|
|
115
119
|
const isSegwit =
|
|
@@ -120,12 +124,12 @@ export function estimateTxSize(
|
|
|
120
124
|
// P2SH: 32 PrevTxHash + 4 Index + 23 scriptPubKey + 4 sequence
|
|
121
125
|
const isNativeSegwit = derivationMode === DerivationModes.NATIVE_SEGWIT;
|
|
122
126
|
const inputSize = isNativeSegwit ? 41 : 63;
|
|
123
|
-
const noWitness = fixedSize + inputSize * inputCount +
|
|
127
|
+
const noWitness = fixedSize + inputSize * inputCount + 43 * outputCount; //43 is the biggest output(taproot output) size, we use the biggest one for safety
|
|
124
128
|
// Include flag and marker size (one byte each)
|
|
125
129
|
const witnessSize = noWitness + 108 * inputCount + 2;
|
|
126
130
|
txSize = (noWitness * 3 + witnessSize) / 4;
|
|
127
131
|
} else {
|
|
128
|
-
txSize = fixedSize + 148 * inputCount +
|
|
132
|
+
txSize = fixedSize + 148 * inputCount + 43 * outputCount;
|
|
129
133
|
}
|
|
130
134
|
return Math.ceil(txSize); // We don't allow floating value
|
|
131
135
|
}
|