Skip to content
23 changes: 23 additions & 0 deletions packages/hdwallet-core/src/bip85.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export interface Bip85GetMnemonicMsg {
wordCount: 12 | 18 | 24;
index: number;
}

/** Firmware displays the seed on-device only; nothing is returned over USB. */
export interface Bip85DisplayResult {
displayed: boolean;
}

/** @deprecated Firmware no longer sends mnemonic over USB. Use Bip85DisplayResult. */
export interface Bip85Mnemonic {
mnemonic: string;
}

export interface Bip85Wallet {
readonly _supportsBip85: boolean;
bip85GetMnemonic(msg: Bip85GetMnemonicMsg): Promise<Bip85DisplayResult>;
}

export function supportsBip85(wallet: any): wallet is Bip85Wallet {
return wallet?._supportsBip85 === true;
}
3 changes: 3 additions & 0 deletions packages/hdwallet-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./arkeo";
export * from "./bip85";
export * from "./bitcoin";
export * from "./cosmos";
export * from "./osmosis";
Expand All @@ -14,6 +15,8 @@ export * from "./ripple";
export * from "./secret";
export * from "./solana";
export * from "./terra";
export * from "./tron";
export * from "./ton";
export * from "./thorchain";
export * from "./mayachain";
export * from "./transport";
Expand Down
51 changes: 51 additions & 0 deletions packages/hdwallet-core/src/ton.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { BIP32Path, HDWallet, HDWalletInfo } from "./wallet";

export interface TonGetAddress {
addressNList: BIP32Path;
showDisplay?: boolean;
bounceable?: boolean;
testnet?: boolean;
workchain?: number;
}

export interface TonAddress {
address: string;
rawAddress?: string;
}

export interface TonSignTx {
addressNList: BIP32Path;
rawTx: Uint8Array | string;
expireAt?: number;
seqno?: number;
workchain?: number;
toAddress?: string;
amount?: string; // nanoTON as string (uint64)
bounce?: boolean;
memo?: string;
isDeploy?: boolean;
}

export interface TonSignedTx {
signature: Uint8Array | string;
}

export interface TonGetAccountPaths {
accountIdx: number;
}

export interface TonAccountPath {
addressNList: BIP32Path;
}

export interface TonWalletInfo extends HDWalletInfo {
readonly _supportsTonInfo: boolean;
tonGetAccountPaths(msg: TonGetAccountPaths): Array<TonAccountPath>;
tonNextAccountPath(msg: TonAccountPath): TonAccountPath | undefined;
}

export interface TonWallet extends TonWalletInfo, HDWallet {
readonly _supportsTon: boolean;
tonGetAddress(msg: TonGetAddress): Promise<string | null>;
tonSignTx(msg: TonSignTx): Promise<TonSignedTx | null>;
}
41 changes: 41 additions & 0 deletions packages/hdwallet-core/src/tron.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { BIP32Path, HDWallet, HDWalletInfo } from "./wallet";

export interface TronGetAddress {
addressNList: BIP32Path;
showDisplay?: boolean;
}

export interface TronAddress {
address: string;
}

export interface TronSignTx {
addressNList: BIP32Path;
rawTx: Uint8Array | string;
toAddress?: string; // Destination address — enables clear-sign on device
amount?: string; // Amount in SUN (string to avoid precision loss) — enables clear-sign on device
}

export interface TronSignedTx {
signature: Uint8Array | string;
}

export interface TronGetAccountPaths {
accountIdx: number;
}

export interface TronAccountPath {
addressNList: BIP32Path;
}

export interface TronWalletInfo extends HDWalletInfo {
readonly _supportsTronInfo: boolean;
tronGetAccountPaths(msg: TronGetAccountPaths): Array<TronAccountPath>;
tronNextAccountPath(msg: TronAccountPath): TronAccountPath | undefined;
}

export interface TronWallet extends TronWalletInfo, HDWallet {
readonly _supportsTron: boolean;
tronGetAddress(msg: TronGetAddress): Promise<string | null>;
tronSignTx(msg: TronSignTx): Promise<TronSignedTx | null>;
}
2 changes: 2 additions & 0 deletions packages/hdwallet-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ const slip44Table = Object.freeze({
Mayachain: 931,
Cacao: 931,
Solana: 501,
Tron: 195,
Ton: 607,
} as const);
type Slip44ByCoin<T> = T extends keyof typeof slip44Table ? (typeof slip44Table)[T] : number | undefined;
export function slip44ByCoin<T extends Coin>(coin: T): Slip44ByCoin<T> {
Expand Down
2 changes: 1 addition & 1 deletion packages/hdwallet-keepkey/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"@ethereumjs/common": "^2.4.0",
"@ethereumjs/tx": "^3.3.0",
"@keepkey/device-protocol": "^7.13.2",
"@keepkey/device-protocol": "npm:@bithighlander/device-protocol@7.14.1",
"@keepkey/hdwallet-core": "1.53.16",
"@keepkey/proto-tx-builder": "^0.9.1",
"@metamask/eth-sig-util": "^7.0.0",
Expand Down
10 changes: 8 additions & 2 deletions packages/hdwallet-keepkey/src/bitcoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const supportedCoins = [
"Dogecoin",
"Zcash",
"Komodo",
"Zcash",
"Lynx",
];

const segwitCoins = ["Bitcoin", "Testnet", "BitcoinGold", "Litecoin"];
Expand Down Expand Up @@ -111,7 +111,7 @@ function prepareSignTx(
const txmap: Record<string, unknown> = {}; // Create a map of transactions by txid needed for the KeepKey signing flow.
txmap["unsigned"] = unsignedTx;

const forceBip143Coins = ["BitcoinGold", "BitcoinCash", "BitcoinSV"];
const forceBip143Coins = ["BitcoinGold", "BitcoinCash", "BitcoinSV", "Zcash"];
if (forceBip143Coins.includes(coin)) return txmap;

inputs.forEach((inputTx) => {
Expand Down Expand Up @@ -313,6 +313,12 @@ export async function btcSignTx(
tx.setCoinName(msg.coin);
if (msg.version !== undefined) tx.setVersion(msg.version);
tx.setLockTime(msg.locktime || 0);
if ((msg as any).overwintered) {
tx.setOverwintered(true);
if ((msg as any).versionGroupId !== undefined) tx.setVersionGroupId((msg as any).versionGroupId);
if ((msg as any).branchId !== undefined) tx.setBranchId((msg as any).branchId);
}
if ((msg as any).expiry !== undefined) tx.setExpiry((msg as any).expiry);

let responseType: number | undefined;
let response: any;
Expand Down
3 changes: 3 additions & 0 deletions packages/hdwallet-keepkey/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export * from "./adapter";
export * from "./keepkey";
export * from "./solana";
export * from "./tron";
export * from "./ton";
export * from "./zcash";
export * from "./transport";
export * from "./typeRegistry";
export * from "./utils";
Loading
Loading