-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make KK parse its own TXes to avoid type hell #363
Changes from all commits
e9ff829
6426fb2
2f272ef
8376339
38829e0
37ddb4c
1a6b963
68bfa5d
72922d4
91cf696
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
import * as ta from "type-assertions"; | ||
|
||
import { addressNListToBIP32, slip44ByCoin } from "./utils"; | ||
import { BIP32Path, Coin, ExchangeType, HDWallet, HDWalletInfo, PathDescription } from "./wallet"; | ||
|
||
|
@@ -28,7 +30,6 @@ export interface BitcoinScriptSig { | |
* Deserialized representation of an already-signed input of a transaction. | ||
*/ | ||
interface BitcoinInputBase { | ||
valueSat: number; | ||
sequence: number; | ||
} | ||
export type BitcoinInput = GuardedUnion< | ||
|
@@ -106,12 +107,19 @@ type BTCSignTxInputKKBase = BTCSignTxInputBase & { | |
|
||
type BTCSignTxInputKKSegwit = BTCSignTxInputKKBase & { | ||
scriptType: BTCInputScriptType.SpendWitness | BTCInputScriptType.SpendP2SHWitness | BTCInputScriptType.External; | ||
hex?: string; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is just to make |
||
}; | ||
|
||
type BTCSignTxInputKKNonSegwit = BTCSignTxInputKKBase & { | ||
scriptType: Exclude<BTCInputScriptType, BTCSignTxInputKKSegwit["scriptType"]>; | ||
tx: BitcoinTx; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this whole |
||
}; | ||
} & ( | ||
| { | ||
tx: BitcoinTx; | ||
} | ||
| { | ||
hex: string; | ||
} | ||
); | ||
|
||
type BTCSignTxInputKKUnguarded = BTCSignTxInputKKNonSegwit | BTCSignTxInputKKSegwit; | ||
export type BTCSignTxInputKK = GuardedUnion<BTCSignTxInputKKUnguarded>; | ||
|
@@ -129,7 +137,21 @@ export type BTCSignTxInputLedger = BTCSignTxInputBase & { | |
}; | ||
|
||
export type BTCSignTxInput = BTCSignTxInputNative & BTCSignTxInputKK & BTCSignTxInputTrezor & BTCSignTxInputLedger; | ||
export type BTCSignTxInputUnguarded = BTCSignTxInputNativeUnguarded & BTCSignTxInputKKUnguarded & BTCSignTxInputTrezor & BTCSignTxInputLedger; | ||
export type BTCSignTxInputUnguarded = BTCSignTxInputNativeUnguarded & | ||
BTCSignTxInputKKUnguarded & | ||
BTCSignTxInputTrezor & | ||
BTCSignTxInputLedger; | ||
|
||
// Stick to this common subset of input fields to avoid type hell. | ||
export type BTCSignTxInputSafe = { | ||
addressNList: BIP32Path; | ||
scriptType: BTCInputScriptType; | ||
hex: string; | ||
txid: string; | ||
amount: string; | ||
vout: number; | ||
}; | ||
ta.assert<ta.Extends<BTCSignTxInputSafe, BTCSignTxInput>>(); | ||
|
||
/** | ||
* Output for a transaction we're about to sign. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no clue where this came from, but we don't use it anywhere.