Skip to content

feat(sdk-core): added OFC BitGo signing on trading accounts object#8666

Open
alextse-bg wants to merge 3 commits intomasterfrom
WCN-217
Open

feat(sdk-core): added OFC BitGo signing on trading accounts object#8666
alextse-bg wants to merge 3 commits intomasterfrom
WCN-217

Conversation

@alextse-bg
Copy link
Copy Markdown
Contributor

TICKET: WCN-217

@linear
Copy link
Copy Markdown

linear Bot commented Apr 30, 2026

@alextse-bg alextse-bg force-pushed the WCN-217 branch 5 times, most recently from 4f679c7 to 467a1cc Compare May 5, 2026 16:19
alextse-bg and others added 3 commits May 5, 2026 12:21
make wallet passphrase optional when signing trading account TXs
allow the use of prv when signing trading account TXs

Ticket: WCN-217-1
When no walletPassphrase is present in the request body or environment,
pass undefined to tradingAccount.signPayload() instead of throwing.
The SDK routes passphrase-less signing through KMS internally.

Ticket: WCN-215-1
@alextse-bg
Copy link
Copy Markdown
Contributor Author

reimplements the reverted PR: #8624

Taken out the changes to ofcToken/ofc.ts. Changes to these files has no impact on current code path (since we are signing with the user key right now, prv is always passed in). Removing those changes to keep things simple. If there is a need to make the SDK more flexible we can re-introduce the changes.

@alextse-bg
Copy link
Copy Markdown
Contributor Author

@claude

@alextse-bg alextse-bg marked this pull request as ready for review May 5, 2026 17:02
@alextse-bg alextse-bg requested review from a team as code owners May 5, 2026 17:02
@alextse-bg alextse-bg changed the title chore: fixup feat(sdk-core): added OFC BitGo signing on trading accounts object May 5, 2026
@alextse-bg alextse-bg requested a review from zahin-mohammad May 5, 2026 18:13
const prv = await this.wallet.getPrv({ walletPassphrase });
const signedBuffer: Buffer = await this.wallet.baseCoin.signMessage({ prv }, payload);
const signature = signedBuffer.toString('hex');
const signature = await this.wallet.toTradingAccount().signPayload({ payload, walletPassphrase });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should prepareAllocation fail fast when walletPassphrase / prv is missing but the wallet requires user signing (if that flag is knowable without extra round trips), instead of building the payload and failing at sign time?

Copy link
Copy Markdown
Contributor

@zahin-mohammad zahin-mohammad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general lgtm, but please address the as any


/**
* Parameters for the signing a payload from the trading account.
* If both walletPassphrase and prv is not provided the BitGo key will be used
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should note that this is only valid when they have the wallet setting enabled.

payload: string | Record<string, unknown>;
walletPassphrase: string;
walletPassphrase?: string;
prv?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this needed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was what caused the original bug, with the wallets and ofcToken changes, but now I removed it this is no longer need. removed.

if (params.prv) {
prv = params.prv;
} else {
const key = (await this.wallet.baseCoin.keychains().get({ id: this.wallet.keyIds()[0] })) as any;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we casting as any here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants