@vultisig/core-chain 1.1.0 → 1.2.0
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/CHANGELOG.md +42 -0
- package/dist/amount/toChainAmount.d.ts +6 -1
- package/dist/amount/toChainAmount.d.ts.map +1 -1
- package/dist/amount/toChainAmount.js +88 -0
- package/dist/amount/toChainAmount.js.map +1 -1
- package/dist/chains/cosmos/qbtc/claim/BtcAddressType.d.ts +7 -0
- package/dist/chains/cosmos/qbtc/claim/BtcAddressType.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/BtcAddressType.js +9 -0
- package/dist/chains/cosmos/qbtc/claim/BtcAddressType.js.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/ClaimableUtxo.d.ts +8 -0
- package/dist/chains/cosmos/qbtc/claim/ClaimableUtxo.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/ClaimableUtxo.js +2 -0
- package/dist/chains/cosmos/qbtc/claim/ClaimableUtxo.js.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.d.ts +25 -0
- package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.js +43 -0
- package/dist/chains/cosmos/qbtc/claim/broadcastClaimTx.js.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/buildClaimTx.d.ts +26 -0
- package/dist/chains/cosmos/qbtc/claim/buildClaimTx.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/buildClaimTx.js +57 -0
- package/dist/chains/cosmos/qbtc/claim/buildClaimTx.js.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.d.ts +49 -0
- package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.js +85 -0
- package/dist/chains/cosmos/qbtc/claim/computeClaimHashes.js.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/detectBtcAddressType.d.ts +14 -0
- package/dist/chains/cosmos/qbtc/claim/detectBtcAddressType.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/detectBtcAddressType.js +31 -0
- package/dist/chains/cosmos/qbtc/claim/detectBtcAddressType.js.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.d.ts +3 -0
- package/dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.js +13 -0
- package/dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.js.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.d.ts +14 -0
- package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.js +22 -0
- package/dist/chains/cosmos/qbtc/claim/getClaimableUtxos.js.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/proofService.d.ts +50 -0
- package/dist/chains/cosmos/qbtc/claim/proofService.d.ts.map +1 -0
- package/dist/chains/cosmos/qbtc/claim/proofService.js +71 -0
- package/dist/chains/cosmos/qbtc/claim/proofService.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/halts.d.ts +56 -0
- package/dist/chains/cosmos/thor/lp/halts.d.ts.map +1 -0
- package/dist/chains/cosmos/thor/lp/halts.js +95 -0
- package/dist/chains/cosmos/thor/lp/halts.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/index.d.ts +34 -11
- package/dist/chains/cosmos/thor/lp/index.d.ts.map +1 -1
- package/dist/chains/cosmos/thor/lp/index.js +9 -15
- package/dist/chains/cosmos/thor/lp/index.js.map +1 -1
- package/dist/chains/cosmos/thor/lp/lockup.d.ts +47 -0
- package/dist/chains/cosmos/thor/lp/lockup.d.ts.map +1 -0
- package/dist/chains/cosmos/thor/lp/lockup.js +56 -0
- package/dist/chains/cosmos/thor/lp/lockup.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/lpChainMap.d.ts +25 -0
- package/dist/chains/cosmos/thor/lp/lpChainMap.d.ts.map +1 -0
- package/dist/chains/cosmos/thor/lp/lpChainMap.js +30 -0
- package/dist/chains/cosmos/thor/lp/lpChainMap.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/math.d.ts +129 -0
- package/dist/chains/cosmos/thor/lp/math.d.ts.map +1 -0
- package/dist/chains/cosmos/thor/lp/math.js +227 -0
- package/dist/chains/cosmos/thor/lp/math.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/memberPool.d.ts +4 -0
- package/dist/chains/cosmos/thor/lp/memberPool.d.ts.map +1 -0
- package/dist/chains/cosmos/thor/lp/memberPool.js +24 -0
- package/dist/chains/cosmos/thor/lp/memberPool.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/memo.d.ts +38 -17
- package/dist/chains/cosmos/thor/lp/memo.d.ts.map +1 -1
- package/dist/chains/cosmos/thor/lp/memo.js +40 -16
- package/dist/chains/cosmos/thor/lp/memo.js.map +1 -1
- package/dist/chains/cosmos/thor/lp/pairing.d.ts +30 -0
- package/dist/chains/cosmos/thor/lp/pairing.d.ts.map +1 -0
- package/dist/chains/cosmos/thor/lp/pairing.js +44 -0
- package/dist/chains/cosmos/thor/lp/pairing.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/payload.d.ts +30 -10
- package/dist/chains/cosmos/thor/lp/payload.d.ts.map +1 -1
- package/dist/chains/cosmos/thor/lp/payload.js +30 -18
- package/dist/chains/cosmos/thor/lp/payload.js.map +1 -1
- package/dist/chains/cosmos/thor/lp/position.d.ts +15 -22
- package/dist/chains/cosmos/thor/lp/position.d.ts.map +1 -1
- package/dist/chains/cosmos/thor/lp/position.js +82 -35
- package/dist/chains/cosmos/thor/lp/position.js.map +1 -1
- package/dist/chains/cosmos/thor/lp/positions.d.ts +15 -0
- package/dist/chains/cosmos/thor/lp/positions.d.ts.map +1 -0
- package/dist/chains/cosmos/thor/lp/positions.js +47 -0
- package/dist/chains/cosmos/thor/lp/positions.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/types.d.ts +45 -0
- package/dist/chains/cosmos/thor/lp/types.d.ts.map +1 -0
- package/dist/chains/cosmos/thor/lp/types.js +2 -0
- package/dist/chains/cosmos/thor/lp/types.js.map +1 -0
- package/dist/chains/cosmos/thor/lp/validation.d.ts +32 -7
- package/dist/chains/cosmos/thor/lp/validation.d.ts.map +1 -1
- package/dist/chains/cosmos/thor/lp/validation.js +76 -11
- package/dist/chains/cosmos/thor/lp/validation.js.map +1 -1
- package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts +21 -0
- package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts.map +1 -0
- package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js +182 -0
- package/dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js.map +1 -0
- package/package.json +90 -5
- package/dist/chains/cosmos/thor/lp/affiliate.d.ts +0 -16
- package/dist/chains/cosmos/thor/lp/affiliate.d.ts.map +0 -1
- package/dist/chains/cosmos/thor/lp/affiliate.js +0 -16
- package/dist/chains/cosmos/thor/lp/affiliate.js.map +0 -1
|
@@ -10,26 +10,91 @@ const extractPoolStatus = (raw) => {
|
|
|
10
10
|
return undefined;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Build the mimir flag key THORChain uses to pause LP deposits for a
|
|
14
|
+
* single pool. Format: `PAUSELPDEPOSIT-{CHAIN}-{ASSET_PLUS_CONTRACT}`.
|
|
14
15
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* Examples:
|
|
17
|
+
* BTC.BTC → PAUSELPDEPOSIT-BTC-BTC
|
|
18
|
+
* DOGE.DOGE → PAUSELPDEPOSIT-DOGE-DOGE
|
|
19
|
+
* ETH.USDC-0XA0B... → PAUSELPDEPOSIT-ETH-USDC-0XA0B...
|
|
18
20
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* Note: `CHAIN.ASSET` splits on the FIRST `.`; the rest (including any
|
|
22
|
+
* `-CONTRACT` suffix) is the asset portion, which is appended with a
|
|
23
|
+
* single `-` separator.
|
|
24
|
+
*/
|
|
25
|
+
export const poolPauseMimirKey = (pool) => {
|
|
26
|
+
const dotIdx = pool.indexOf('.');
|
|
27
|
+
if (dotIdx <= 0 || dotIdx >= pool.length - 1) {
|
|
28
|
+
throw new Error(`poolPauseMimirKey: invalid pool id ${pool}`);
|
|
29
|
+
}
|
|
30
|
+
const chain = pool.slice(0, dotIdx);
|
|
31
|
+
const asset = pool.slice(dotIdx + 1);
|
|
32
|
+
return `PAUSELPDEPOSIT-${chain}-${asset}`;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Fetch the raw thornode mimir map. Returns an object with flag keys as
|
|
36
|
+
* numbers. Used to check per-pool LP deposit pauses (PAUSELPDEPOSIT-*),
|
|
37
|
+
* liquidity lockup (LIQUIDITYLOCKUPBLOCKS), etc.
|
|
38
|
+
*/
|
|
39
|
+
export const getThorchainMimir = async () => {
|
|
40
|
+
const url = `${cosmosRpcUrl[Chain.THORChain]}/thorchain/mimir`;
|
|
41
|
+
const raw = await queryUrl(url);
|
|
42
|
+
if (!raw || typeof raw !== 'object') {
|
|
43
|
+
throw new Error(`getThorchainMimir: unexpected response shape from ${url}`);
|
|
44
|
+
}
|
|
45
|
+
// thornode /thorchain/mimir returns numeric values, but the JSON could
|
|
46
|
+
// deserialize as number or numeric string depending on the upstream
|
|
47
|
+
// proxy. Normalize to number, drop entries we can't coerce — downstream
|
|
48
|
+
// callers do `typeof v === 'number' && v > 0` checks anyway, and a NaN
|
|
49
|
+
// would silently defeat those.
|
|
50
|
+
const out = {};
|
|
51
|
+
for (const [k, v] of Object.entries(raw)) {
|
|
52
|
+
if (typeof v === 'number' && Number.isFinite(v)) {
|
|
53
|
+
out[k] = v;
|
|
54
|
+
}
|
|
55
|
+
else if (typeof v === 'string' && /^-?\d+$/.test(v)) {
|
|
56
|
+
out[k] = Number(v);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Verify a THORChain pool is currently depositable. Checks TWO layers:
|
|
63
|
+
*
|
|
64
|
+
* 1. **Thornode pool status** — `/thorchain/pool/{asset}.status` must be
|
|
65
|
+
* `Available`. Catches staged / suspended pools.
|
|
66
|
+
* 2. **Mimir per-pool pause flag** — `PAUSELPDEPOSIT-{chain}-{asset}`
|
|
67
|
+
* must not be set. Catches the case where the pool is listed as
|
|
68
|
+
* available BUT the THORChain handler rejects LP adds for it via
|
|
69
|
+
* mimir (what happened to BTC.BTC on 2026-04-10: pool.status was
|
|
70
|
+
* `Available`, deposits silently accepted into mempool, handler
|
|
71
|
+
* rejected at execution with "deposits are paused for asset
|
|
72
|
+
* (btc.btc): internal error"). Without the mimir check, the user
|
|
73
|
+
* signs a tx that is guaranteed to fail on-chain.
|
|
74
|
+
*
|
|
75
|
+
* Use this as the fail-fast gate before building an LP add payload.
|
|
22
76
|
*/
|
|
23
77
|
export const assertPoolDepositable = async (pool) => {
|
|
24
78
|
assertValidPoolId(pool);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
79
|
+
// Run both checks in parallel — they hit different endpoints so there
|
|
80
|
+
// is no reason to serialize them.
|
|
81
|
+
const [poolRaw, mimir] = await Promise.all([
|
|
82
|
+
queryUrl(`${cosmosRpcUrl[Chain.THORChain]}/thorchain/pool/${encodeURIComponent(pool)}`),
|
|
83
|
+
getThorchainMimir(),
|
|
84
|
+
]);
|
|
85
|
+
// Check 1: thornode pool.status
|
|
86
|
+
const status = extractPoolStatus(poolRaw);
|
|
28
87
|
if (status === undefined) {
|
|
29
|
-
throw new Error(`assertPoolDepositable: pool ${pool} response from
|
|
88
|
+
throw new Error(`assertPoolDepositable: pool ${pool} response from thornode did not include a string \`status\` field`);
|
|
30
89
|
}
|
|
31
90
|
if (status !== 'Available') {
|
|
32
91
|
throw new Error(`assertPoolDepositable: pool ${pool} status is ${status}, must be Available for LP add`);
|
|
33
92
|
}
|
|
93
|
+
// Check 2: mimir per-pool PAUSELPDEPOSIT flag
|
|
94
|
+
const pauseKey = poolPauseMimirKey(pool);
|
|
95
|
+
const pauseValue = mimir[pauseKey];
|
|
96
|
+
if (typeof pauseValue === 'number' && pauseValue > 0) {
|
|
97
|
+
throw new Error(`assertPoolDepositable: pool ${pool} has LP deposits paused on-chain via mimir ${pauseKey}=${pauseValue}. THORChain validators have disabled new adds for this pool; any tx would be rejected at handler execution time.`);
|
|
98
|
+
}
|
|
34
99
|
};
|
|
35
100
|
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAA;AAC9E,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAA;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAE3C,MAAM,iBAAiB,GAAG,CAAC,GAAY,EAAsB,EAAE;IAC7D,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,QAAQ,IAAI,GAAG,EAAE,CAAC;QACtD,MAAM,MAAM,GAAI,GAA2B,CAAC,MAAM,CAAA;QAClD,OAAO,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAA;IACxD,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED
|
|
1
|
+
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/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MAAM,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAA;IACzC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,mEAAmE,CACvG,CAAA;IACH,CAAC;IACD,IAAI,MAAM,KAAK,WAAW,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,cAAc,MAAM,gCAAgC,CACxF,CAAA;IACH,CAAC;IAED,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;IACxC,MAAM,UAAU,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAA;IAClC,IAAI,OAAO,UAAU,KAAK,QAAQ,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACrD,MAAM,IAAI,KAAK,CACb,+BAA+B,IAAI,8CAA8C,QAAQ,IAAI,UAAU,kHAAkH,CAC1N,CAAA;IACH,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SignBitcoin } from '@vultisig/core-mpc/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb';
|
|
2
|
+
import { Network, Psbt } from 'bitcoinjs-lib';
|
|
3
|
+
type BuildSignBitcoinFromPsbtInput = {
|
|
4
|
+
psbt: Psbt;
|
|
5
|
+
senderAddress: string;
|
|
6
|
+
/** Bitcoin network for address decoding. Defaults to mainnet. */
|
|
7
|
+
network?: Network;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Decompose a BIP-174 PSBT into a structured SignBitcoin proto message.
|
|
11
|
+
* Co-signing devices can verify every input/output and compute exact sighashes
|
|
12
|
+
* from these fields without receiving an opaque blob.
|
|
13
|
+
*
|
|
14
|
+
* Currently supports P2WPKH and P2SH-P2WPKH inputs only.
|
|
15
|
+
* P2TR (Taproot/BIP-341) requires a different sighash algorithm and is planned for follow-up.
|
|
16
|
+
* P2PKH (legacy) requires legacy sighash (not BIP-143).
|
|
17
|
+
* See https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
|
|
18
|
+
*/
|
|
19
|
+
export declare const buildSignBitcoinFromPsbt: ({ psbt, senderAddress, network, }: BuildSignBitcoinFromPsbtInput) => SignBitcoin;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=buildSignBitcoinFromPsbt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSignBitcoinFromPsbt.d.ts","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/utxo/tx/buildSignBitcoinFromPsbt.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,WAAW,EAEZ,MAAM,+EAA+E,CAAA;AACtF,OAAO,EAEL,OAAO,EAGP,IAAI,EAGL,MAAM,eAAe,CAAA;AAsEtB,KAAK,6BAA6B,GAAG;IACnC,IAAI,EAAE,IAAI,CAAA;IACV,aAAa,EAAE,MAAM,CAAA;IACrB,iEAAiE;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,GAAI,mCAItC,6BAA6B,KAAG,WA4IlC,CAAA"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { create } from '@bufbuild/protobuf';
|
|
2
|
+
import { BitcoinInputSchema, BitcoinOutputSchema, SignBitcoinSchema, } from '@vultisig/core-mpc/types/vultisig/keysign/v1/wasm_execute_contract_payload_pb';
|
|
3
|
+
import { address as btcAddress, networks, opcodes, script as bscript, Transaction, } from 'bitcoinjs-lib';
|
|
4
|
+
/**
|
|
5
|
+
* Detect the script type from a scriptPubKey buffer.
|
|
6
|
+
* See https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki
|
|
7
|
+
*/
|
|
8
|
+
const detectScriptType = (scriptPubKey, redeemScript) => {
|
|
9
|
+
// P2WPKH: OP_0 PUSH_20 <20-byte-hash> (22 bytes)
|
|
10
|
+
if (scriptPubKey.length === 22 && scriptPubKey[0] === 0x00 && scriptPubKey[1] === 0x14) {
|
|
11
|
+
return 'p2wpkh';
|
|
12
|
+
}
|
|
13
|
+
// P2PKH: OP_DUP OP_HASH160 PUSH_20 <20-byte-hash> OP_EQUALVERIFY OP_CHECKSIG (25 bytes)
|
|
14
|
+
if (scriptPubKey.length === 25 &&
|
|
15
|
+
scriptPubKey[0] === 0x76 &&
|
|
16
|
+
scriptPubKey[1] === 0xa9 &&
|
|
17
|
+
scriptPubKey[2] === 0x14 &&
|
|
18
|
+
scriptPubKey[23] === 0x88 &&
|
|
19
|
+
scriptPubKey[24] === 0xac) {
|
|
20
|
+
return 'p2pkh';
|
|
21
|
+
}
|
|
22
|
+
// P2TR: OP_1 PUSH_32 <32-byte-key> (34 bytes)
|
|
23
|
+
if (scriptPubKey.length === 34 && scriptPubKey[0] === 0x51 && scriptPubKey[1] === 0x20) {
|
|
24
|
+
return 'p2tr';
|
|
25
|
+
}
|
|
26
|
+
// P2WSH: OP_0 PUSH_32 <32-byte-hash> (34 bytes)
|
|
27
|
+
if (scriptPubKey.length === 34 && scriptPubKey[0] === 0x00 && scriptPubKey[1] === 0x20) {
|
|
28
|
+
return 'p2wsh';
|
|
29
|
+
}
|
|
30
|
+
// P2SH-P2WPKH: only when redeemScript is a valid P2WPKH witness program
|
|
31
|
+
const redeem = redeemScript ? Buffer.from(redeemScript) : undefined;
|
|
32
|
+
if (scriptPubKey.length === 23 &&
|
|
33
|
+
scriptPubKey[0] === 0xa9 &&
|
|
34
|
+
scriptPubKey[1] === 0x14 &&
|
|
35
|
+
scriptPubKey[22] === 0x87 &&
|
|
36
|
+
redeem?.length === 22 &&
|
|
37
|
+
redeem[0] === 0x00 &&
|
|
38
|
+
redeem[1] === 0x14) {
|
|
39
|
+
return 'p2sh-p2wpkh';
|
|
40
|
+
}
|
|
41
|
+
return 'unknown';
|
|
42
|
+
};
|
|
43
|
+
/** Script types that computePreSigningHashes can produce sighashes for. */
|
|
44
|
+
const SUPPORTED_SCRIPT_TYPES = new Set(['p2wpkh', 'p2sh-p2wpkh']);
|
|
45
|
+
const isOpReturn = (script) => {
|
|
46
|
+
const chunks = bscript.decompile(script);
|
|
47
|
+
return chunks !== null && chunks[0] === opcodes.OP_RETURN;
|
|
48
|
+
};
|
|
49
|
+
const getOpReturnHex = (script) => {
|
|
50
|
+
const chunks = bscript.decompile(script);
|
|
51
|
+
if (!chunks || chunks[0] !== opcodes.OP_RETURN)
|
|
52
|
+
return undefined;
|
|
53
|
+
const dataChunks = chunks
|
|
54
|
+
.slice(1)
|
|
55
|
+
.filter((chunk) => Buffer.isBuffer(chunk));
|
|
56
|
+
if (dataChunks.length === 0)
|
|
57
|
+
return undefined;
|
|
58
|
+
return Buffer.concat(dataChunks).toString('hex');
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Decompose a BIP-174 PSBT into a structured SignBitcoin proto message.
|
|
62
|
+
* Co-signing devices can verify every input/output and compute exact sighashes
|
|
63
|
+
* from these fields without receiving an opaque blob.
|
|
64
|
+
*
|
|
65
|
+
* Currently supports P2WPKH and P2SH-P2WPKH inputs only.
|
|
66
|
+
* P2TR (Taproot/BIP-341) requires a different sighash algorithm and is planned for follow-up.
|
|
67
|
+
* P2PKH (legacy) requires legacy sighash (not BIP-143).
|
|
68
|
+
* See https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki
|
|
69
|
+
*/
|
|
70
|
+
export const buildSignBitcoinFromPsbt = ({ psbt, senderAddress, network = networks.bitcoin, }) => {
|
|
71
|
+
// Compute anyInputHasBip32 once (not per-input) for O(n) ownership detection
|
|
72
|
+
const anyInputHasBip32 = psbt.data.inputs.some(inp => (inp.bip32Derivation && inp.bip32Derivation.length > 0) ||
|
|
73
|
+
(inp.tapBip32Derivation &&
|
|
74
|
+
inp.tapBip32Derivation.length > 0));
|
|
75
|
+
const inputs = psbt.txInputs.map((txInput, i) => {
|
|
76
|
+
const inputData = psbt.data.inputs[i];
|
|
77
|
+
// Prefer witnessUtxo; fall back to nonWitnessUtxo (full prev tx)
|
|
78
|
+
let scriptPubKey;
|
|
79
|
+
let inputValue;
|
|
80
|
+
if (inputData.witnessUtxo) {
|
|
81
|
+
scriptPubKey = Buffer.from(inputData.witnessUtxo.script);
|
|
82
|
+
inputValue = BigInt(inputData.witnessUtxo.value);
|
|
83
|
+
// Fee snipe mitigation: cross-validate against nonWitnessUtxo if present.
|
|
84
|
+
// A malicious PSBT can lie about witnessUtxo.value; BIP-143 commits to it
|
|
85
|
+
// in the sighash, causing excess fees if the actual UTXO is worth more.
|
|
86
|
+
// See https://blog.trezor.io/details-of-the-multisig-change-address-issue-and-its-mitigation-6370ad73ed2a
|
|
87
|
+
if (inputData.nonWitnessUtxo) {
|
|
88
|
+
const prevTx = Transaction.fromBuffer(Buffer.from(inputData.nonWitnessUtxo));
|
|
89
|
+
// BIP-174: verify nonWitnessUtxo txid matches the input's prevout hash
|
|
90
|
+
const prevTxId = prevTx.getId();
|
|
91
|
+
const expectedTxId = Buffer.from(txInput.hash).reverse().toString('hex');
|
|
92
|
+
if (prevTxId !== expectedTxId) {
|
|
93
|
+
throw new Error(`Input #${i}: nonWitnessUtxo txid (${prevTxId.slice(0, 16)}...) does not match ` +
|
|
94
|
+
`input prevout (${expectedTxId.slice(0, 16)}...)`);
|
|
95
|
+
}
|
|
96
|
+
const prevOutput = prevTx.outs[txInput.index];
|
|
97
|
+
if (prevOutput && BigInt(prevOutput.value) !== inputValue) {
|
|
98
|
+
throw new Error(`Input #${i}: witnessUtxo value (${inputValue}) does not match ` +
|
|
99
|
+
`nonWitnessUtxo value (${prevOutput.value}) - possible fee snipe`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (inputData.nonWitnessUtxo) {
|
|
104
|
+
const prevTx = Transaction.fromBuffer(Buffer.from(inputData.nonWitnessUtxo));
|
|
105
|
+
const prevOutput = prevTx.outs[txInput.index];
|
|
106
|
+
if (!prevOutput) {
|
|
107
|
+
throw new Error(`Input #${i}: nonWitnessUtxo has no output at index ${txInput.index}`);
|
|
108
|
+
}
|
|
109
|
+
scriptPubKey = Buffer.from(prevOutput.script);
|
|
110
|
+
inputValue = BigInt(prevOutput.value);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
throw new Error(`Input #${i} missing both witnessUtxo and nonWitnessUtxo`);
|
|
114
|
+
}
|
|
115
|
+
if (inputValue < 0n) {
|
|
116
|
+
throw new Error(`Input #${i}: negative amount (${inputValue})`);
|
|
117
|
+
}
|
|
118
|
+
const scriptType = detectScriptType(scriptPubKey, inputData.redeemScript);
|
|
119
|
+
// Fail early for unsupported script types rather than at sighash time.
|
|
120
|
+
// This gives a clearer error at decomposition time.
|
|
121
|
+
const hasBip32 = (inputData.bip32Derivation && inputData.bip32Derivation.length > 0) ||
|
|
122
|
+
(inputData.tapBip32Derivation &&
|
|
123
|
+
inputData.tapBip32Derivation.length > 0);
|
|
124
|
+
const isOurs = anyInputHasBip32 ? !!hasBip32 : true;
|
|
125
|
+
if (isOurs && !SUPPORTED_SCRIPT_TYPES.has(scriptType)) {
|
|
126
|
+
const hints = {
|
|
127
|
+
p2tr: 'P2TR (Taproot) requires BIP-341 sighash. See https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki',
|
|
128
|
+
p2pkh: 'P2PKH (legacy) requires legacy sighash, not BIP-143.',
|
|
129
|
+
p2wsh: 'P2WSH requires BIP-143 with the full witnessScript as scriptCode.',
|
|
130
|
+
unknown: `Unrecognized scriptPubKey: ${scriptPubKey.toString('hex')}`,
|
|
131
|
+
};
|
|
132
|
+
throw new Error(`Input #${i}: unsupported script type '${scriptType}' for signing. ${hints[scriptType] ?? ''}`);
|
|
133
|
+
}
|
|
134
|
+
const sighashType = inputData.sighashType ?? 1; // SIGHASH_ALL
|
|
135
|
+
const redeemScript = inputData.redeemScript
|
|
136
|
+
? Buffer.from(inputData.redeemScript).toString('hex')
|
|
137
|
+
: undefined;
|
|
138
|
+
return create(BitcoinInputSchema, {
|
|
139
|
+
hash: Buffer.from(txInput.hash).reverse().toString('hex'),
|
|
140
|
+
index: txInput.index,
|
|
141
|
+
amount: inputValue,
|
|
142
|
+
scriptPubKey: scriptPubKey.toString('hex'),
|
|
143
|
+
scriptType,
|
|
144
|
+
sighashType,
|
|
145
|
+
isOurs,
|
|
146
|
+
redeemScript,
|
|
147
|
+
sequence: txInput.sequence,
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
const outputs = psbt.txOutputs.map((txOutput, outputIndex) => {
|
|
151
|
+
const script = Buffer.from(txOutput.script);
|
|
152
|
+
const opReturn = isOpReturn(script);
|
|
153
|
+
let outputAddress = '';
|
|
154
|
+
if (!opReturn) {
|
|
155
|
+
try {
|
|
156
|
+
outputAddress = btcAddress.fromOutputScript(txOutput.script, network);
|
|
157
|
+
}
|
|
158
|
+
catch {
|
|
159
|
+
// Non-standard output - address stays empty
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
// Change detection: Vultisig uses a single address per UTXO chain (no HD change
|
|
163
|
+
// derivation), so address comparison is the primary signal. BIP32 derivation on
|
|
164
|
+
// outputs is NOT used alone because a malicious dApp could inject derivation paths
|
|
165
|
+
// on attacker outputs to disguise them as change. Address match is unforgeable
|
|
166
|
+
// since only the vault owner knows the private key for that address.
|
|
167
|
+
return create(BitcoinOutputSchema, {
|
|
168
|
+
amount: BigInt(txOutput.value),
|
|
169
|
+
address: outputAddress,
|
|
170
|
+
opReturnData: opReturn ? getOpReturnHex(script) : undefined,
|
|
171
|
+
scriptPubKey: script.toString('hex'),
|
|
172
|
+
isChange: outputAddress !== '' && outputAddress === senderAddress,
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
return create(SignBitcoinSchema, {
|
|
176
|
+
version: psbt.version,
|
|
177
|
+
locktime: psbt.locktime,
|
|
178
|
+
inputs,
|
|
179
|
+
outputs,
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
//# sourceMappingURL=buildSignBitcoinFromPsbt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSignBitcoinFromPsbt.js","sourceRoot":"","sources":["../../../../../../../packages/core/chain/chains/utxo/tx/buildSignBitcoinFromPsbt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EAEnB,iBAAiB,GAClB,MAAM,+EAA+E,CAAA;AACtF,OAAO,EACL,OAAO,IAAI,UAAU,EAErB,QAAQ,EACR,OAAO,EAEP,MAAM,IAAI,OAAO,EACjB,WAAW,GACZ,MAAM,eAAe,CAAA;AAKtB;;;GAGG;AACH,MAAM,gBAAgB,GAAG,CACvB,YAAoB,EACpB,YAAyB,EACb,EAAE;IACd,iDAAiD;IACjD,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACvF,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,wFAAwF;IACxF,IACE,YAAY,CAAC,MAAM,KAAK,EAAE;QAC1B,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI;QACxB,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI;QACxB,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI;QACxB,YAAY,CAAC,EAAE,CAAC,KAAK,IAAI;QACzB,YAAY,CAAC,EAAE,CAAC,KAAK,IAAI,EACzB,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IACD,8CAA8C;IAC9C,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,IAAI,YAAY,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACvF,OAAO,MAAM,CAAA;IACf,CAAC;IACD,gDAAgD;IAChD,IAAI,YAAY,CAAC,MAAM,KAAK,EAAE,IAAI,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AAC,QAAQ,CAAC,KAAK,CAAC;YAC9B,OAAO,EAAE,aAAa;YACtB,YAAY,EAAE,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;YAC3D,YAAY,EAAE,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC;YACpC,QAAQ,EAAE,aAAa,KAAK,EAAE,IAAI,aAAa,KAAK,aAAa;SAClE,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAC,iBAAiB,EAAE;QAC/B,OAAO,EAAE,IAAI,CAAC,OAAO;QACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM;QACN,OAAO;KACR,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vultisig/core-chain",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Blockchain chain logic shared across Vultisig clients",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -159,6 +159,51 @@
|
|
|
159
159
|
"import": "./dist/chains/cosmos/gas.js",
|
|
160
160
|
"default": "./dist/chains/cosmos/gas.js"
|
|
161
161
|
},
|
|
162
|
+
"./chains/cosmos/qbtc/claim/broadcastClaimTx": {
|
|
163
|
+
"types": "./dist/chains/cosmos/qbtc/claim/broadcastClaimTx.d.ts",
|
|
164
|
+
"import": "./dist/chains/cosmos/qbtc/claim/broadcastClaimTx.js",
|
|
165
|
+
"default": "./dist/chains/cosmos/qbtc/claim/broadcastClaimTx.js"
|
|
166
|
+
},
|
|
167
|
+
"./chains/cosmos/qbtc/claim/BtcAddressType": {
|
|
168
|
+
"types": "./dist/chains/cosmos/qbtc/claim/BtcAddressType.d.ts",
|
|
169
|
+
"import": "./dist/chains/cosmos/qbtc/claim/BtcAddressType.js",
|
|
170
|
+
"default": "./dist/chains/cosmos/qbtc/claim/BtcAddressType.js"
|
|
171
|
+
},
|
|
172
|
+
"./chains/cosmos/qbtc/claim/buildClaimTx": {
|
|
173
|
+
"types": "./dist/chains/cosmos/qbtc/claim/buildClaimTx.d.ts",
|
|
174
|
+
"import": "./dist/chains/cosmos/qbtc/claim/buildClaimTx.js",
|
|
175
|
+
"default": "./dist/chains/cosmos/qbtc/claim/buildClaimTx.js"
|
|
176
|
+
},
|
|
177
|
+
"./chains/cosmos/qbtc/claim/ClaimableUtxo": {
|
|
178
|
+
"types": "./dist/chains/cosmos/qbtc/claim/ClaimableUtxo.d.ts",
|
|
179
|
+
"import": "./dist/chains/cosmos/qbtc/claim/ClaimableUtxo.js",
|
|
180
|
+
"default": "./dist/chains/cosmos/qbtc/claim/ClaimableUtxo.js"
|
|
181
|
+
},
|
|
182
|
+
"./chains/cosmos/qbtc/claim/computeClaimHashes": {
|
|
183
|
+
"types": "./dist/chains/cosmos/qbtc/claim/computeClaimHashes.d.ts",
|
|
184
|
+
"import": "./dist/chains/cosmos/qbtc/claim/computeClaimHashes.js",
|
|
185
|
+
"default": "./dist/chains/cosmos/qbtc/claim/computeClaimHashes.js"
|
|
186
|
+
},
|
|
187
|
+
"./chains/cosmos/qbtc/claim/detectBtcAddressType": {
|
|
188
|
+
"types": "./dist/chains/cosmos/qbtc/claim/detectBtcAddressType.d.ts",
|
|
189
|
+
"import": "./dist/chains/cosmos/qbtc/claim/detectBtcAddressType.js",
|
|
190
|
+
"default": "./dist/chains/cosmos/qbtc/claim/detectBtcAddressType.js"
|
|
191
|
+
},
|
|
192
|
+
"./chains/cosmos/qbtc/claim/getClaimableUtxos": {
|
|
193
|
+
"types": "./dist/chains/cosmos/qbtc/claim/getClaimableUtxos.d.ts",
|
|
194
|
+
"import": "./dist/chains/cosmos/qbtc/claim/getClaimableUtxos.js",
|
|
195
|
+
"default": "./dist/chains/cosmos/qbtc/claim/getClaimableUtxos.js"
|
|
196
|
+
},
|
|
197
|
+
"./chains/cosmos/qbtc/claim/getClaimWithProofDisabled": {
|
|
198
|
+
"types": "./dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.d.ts",
|
|
199
|
+
"import": "./dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.js",
|
|
200
|
+
"default": "./dist/chains/cosmos/qbtc/claim/getClaimWithProofDisabled.js"
|
|
201
|
+
},
|
|
202
|
+
"./chains/cosmos/qbtc/claim/proofService": {
|
|
203
|
+
"types": "./dist/chains/cosmos/qbtc/claim/proofService.d.ts",
|
|
204
|
+
"import": "./dist/chains/cosmos/qbtc/claim/proofService.js",
|
|
205
|
+
"default": "./dist/chains/cosmos/qbtc/claim/proofService.js"
|
|
206
|
+
},
|
|
162
207
|
"./chains/cosmos/qbtc/getQbtcAccountInfo": {
|
|
163
208
|
"types": "./dist/chains/cosmos/qbtc/getQbtcAccountInfo.d.ts",
|
|
164
209
|
"import": "./dist/chains/cosmos/qbtc/getQbtcAccountInfo.js",
|
|
@@ -209,16 +254,41 @@
|
|
|
209
254
|
"import": "./dist/chains/cosmos/thor/lp/index.js",
|
|
210
255
|
"default": "./dist/chains/cosmos/thor/lp/index.js"
|
|
211
256
|
},
|
|
212
|
-
"./chains/cosmos/thor/lp/
|
|
213
|
-
"types": "./dist/chains/cosmos/thor/lp/
|
|
214
|
-
"import": "./dist/chains/cosmos/thor/lp/
|
|
215
|
-
"default": "./dist/chains/cosmos/thor/lp/
|
|
257
|
+
"./chains/cosmos/thor/lp/halts": {
|
|
258
|
+
"types": "./dist/chains/cosmos/thor/lp/halts.d.ts",
|
|
259
|
+
"import": "./dist/chains/cosmos/thor/lp/halts.js",
|
|
260
|
+
"default": "./dist/chains/cosmos/thor/lp/halts.js"
|
|
261
|
+
},
|
|
262
|
+
"./chains/cosmos/thor/lp/lockup": {
|
|
263
|
+
"types": "./dist/chains/cosmos/thor/lp/lockup.d.ts",
|
|
264
|
+
"import": "./dist/chains/cosmos/thor/lp/lockup.js",
|
|
265
|
+
"default": "./dist/chains/cosmos/thor/lp/lockup.js"
|
|
266
|
+
},
|
|
267
|
+
"./chains/cosmos/thor/lp/lpChainMap": {
|
|
268
|
+
"types": "./dist/chains/cosmos/thor/lp/lpChainMap.d.ts",
|
|
269
|
+
"import": "./dist/chains/cosmos/thor/lp/lpChainMap.js",
|
|
270
|
+
"default": "./dist/chains/cosmos/thor/lp/lpChainMap.js"
|
|
271
|
+
},
|
|
272
|
+
"./chains/cosmos/thor/lp/math": {
|
|
273
|
+
"types": "./dist/chains/cosmos/thor/lp/math.d.ts",
|
|
274
|
+
"import": "./dist/chains/cosmos/thor/lp/math.js",
|
|
275
|
+
"default": "./dist/chains/cosmos/thor/lp/math.js"
|
|
276
|
+
},
|
|
277
|
+
"./chains/cosmos/thor/lp/memberPool": {
|
|
278
|
+
"types": "./dist/chains/cosmos/thor/lp/memberPool.d.ts",
|
|
279
|
+
"import": "./dist/chains/cosmos/thor/lp/memberPool.js",
|
|
280
|
+
"default": "./dist/chains/cosmos/thor/lp/memberPool.js"
|
|
216
281
|
},
|
|
217
282
|
"./chains/cosmos/thor/lp/memo": {
|
|
218
283
|
"types": "./dist/chains/cosmos/thor/lp/memo.d.ts",
|
|
219
284
|
"import": "./dist/chains/cosmos/thor/lp/memo.js",
|
|
220
285
|
"default": "./dist/chains/cosmos/thor/lp/memo.js"
|
|
221
286
|
},
|
|
287
|
+
"./chains/cosmos/thor/lp/pairing": {
|
|
288
|
+
"types": "./dist/chains/cosmos/thor/lp/pairing.d.ts",
|
|
289
|
+
"import": "./dist/chains/cosmos/thor/lp/pairing.js",
|
|
290
|
+
"default": "./dist/chains/cosmos/thor/lp/pairing.js"
|
|
291
|
+
},
|
|
222
292
|
"./chains/cosmos/thor/lp/payload": {
|
|
223
293
|
"types": "./dist/chains/cosmos/thor/lp/payload.d.ts",
|
|
224
294
|
"import": "./dist/chains/cosmos/thor/lp/payload.js",
|
|
@@ -234,6 +304,16 @@
|
|
|
234
304
|
"import": "./dist/chains/cosmos/thor/lp/position.js",
|
|
235
305
|
"default": "./dist/chains/cosmos/thor/lp/position.js"
|
|
236
306
|
},
|
|
307
|
+
"./chains/cosmos/thor/lp/positions": {
|
|
308
|
+
"types": "./dist/chains/cosmos/thor/lp/positions.d.ts",
|
|
309
|
+
"import": "./dist/chains/cosmos/thor/lp/positions.js",
|
|
310
|
+
"default": "./dist/chains/cosmos/thor/lp/positions.js"
|
|
311
|
+
},
|
|
312
|
+
"./chains/cosmos/thor/lp/types": {
|
|
313
|
+
"types": "./dist/chains/cosmos/thor/lp/types.d.ts",
|
|
314
|
+
"import": "./dist/chains/cosmos/thor/lp/types.js",
|
|
315
|
+
"default": "./dist/chains/cosmos/thor/lp/types.js"
|
|
316
|
+
},
|
|
237
317
|
"./chains/cosmos/thor/lp/validation": {
|
|
238
318
|
"types": "./dist/chains/cosmos/thor/lp/validation.d.ts",
|
|
239
319
|
"import": "./dist/chains/cosmos/thor/lp/validation.js",
|
|
@@ -544,6 +624,11 @@
|
|
|
544
624
|
"import": "./dist/chains/utxo/send/validateUtxoRequirements.js",
|
|
545
625
|
"default": "./dist/chains/utxo/send/validateUtxoRequirements.js"
|
|
546
626
|
},
|
|
627
|
+
"./chains/utxo/tx/buildSignBitcoinFromPsbt": {
|
|
628
|
+
"types": "./dist/chains/utxo/tx/buildSignBitcoinFromPsbt.d.ts",
|
|
629
|
+
"import": "./dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js",
|
|
630
|
+
"default": "./dist/chains/utxo/tx/buildSignBitcoinFromPsbt.js"
|
|
631
|
+
},
|
|
547
632
|
"./chains/utxo/tx/ChainPlainUtxo": {
|
|
548
633
|
"types": "./dist/chains/utxo/tx/ChainPlainUtxo.d.ts",
|
|
549
634
|
"import": "./dist/chains/utxo/tx/ChainPlainUtxo.js",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vultisig affiliate identifier on THORChain.
|
|
3
|
-
*
|
|
4
|
-
* THORName "vi" is the Vultisig affiliate, used across iOS, Windows, and now
|
|
5
|
-
* the agent stack to attribute swaps and LP actions on Midgard.
|
|
6
|
-
*
|
|
7
|
-
* Source of truth: VultisigApp/.../THORChainSwaps.swift uses
|
|
8
|
-
* `affiliateFeeAddress = "vi"` and the production memo fixtures
|
|
9
|
-
* (vultisig-ios/.../TestData/thorchainswap.json) carry `:vi:0`.
|
|
10
|
-
*
|
|
11
|
-
* v1 LP ships at 0 bps so we get Midgard affiliate-stats tracking without
|
|
12
|
-
* taking a fee. Bump the bps constant when product agrees.
|
|
13
|
-
*/
|
|
14
|
-
export declare const VULTISIG_AFFILIATE_NAME = "vi";
|
|
15
|
-
export declare const VULTISIG_AFFILIATE_LP_BPS = 0;
|
|
16
|
-
//# sourceMappingURL=affiliate.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"affiliate.d.ts","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/affiliate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,OAAO,CAAA;AAC3C,eAAO,MAAM,yBAAyB,IAAI,CAAA"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Vultisig affiliate identifier on THORChain.
|
|
3
|
-
*
|
|
4
|
-
* THORName "vi" is the Vultisig affiliate, used across iOS, Windows, and now
|
|
5
|
-
* the agent stack to attribute swaps and LP actions on Midgard.
|
|
6
|
-
*
|
|
7
|
-
* Source of truth: VultisigApp/.../THORChainSwaps.swift uses
|
|
8
|
-
* `affiliateFeeAddress = "vi"` and the production memo fixtures
|
|
9
|
-
* (vultisig-ios/.../TestData/thorchainswap.json) carry `:vi:0`.
|
|
10
|
-
*
|
|
11
|
-
* v1 LP ships at 0 bps so we get Midgard affiliate-stats tracking without
|
|
12
|
-
* taking a fee. Bump the bps constant when product agrees.
|
|
13
|
-
*/
|
|
14
|
-
export const VULTISIG_AFFILIATE_NAME = 'vi';
|
|
15
|
-
export const VULTISIG_AFFILIATE_LP_BPS = 0;
|
|
16
|
-
//# sourceMappingURL=affiliate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"affiliate.js","sourceRoot":"","sources":["../../../../../../../../packages/core/chain/chains/cosmos/thor/lp/affiliate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,CAAA;AAC3C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAA"}
|