Skip to content

Commit f17d97c

Browse files
committed
Merge branch 'master' into soeren/settlement-signing
2 parents fc19f4d + 188f7be commit f17d97c

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

client/src/PublicRequest.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type ObjectType = {
77

88
// Returns B if T and B have same keys. Ignores modifiers (readonly, optional)
99
export type Is<T, B> = keyof T extends keyof B ? keyof B extends keyof T ? B : never : never;
10+
export type Transform<T, K extends keyof T, E> = Omit<T, K> & E;
1011

1112
// Base types for Requests
1213
export type BasicRequest = {
@@ -224,16 +225,13 @@ export type SignSwapRequestCommon = SimpleRequest & {
224225
& { senderLabel: string }
225226
) | (
226227
{type: 'BTC'}
227-
& Omit<BitcoinTransactionInfo,
228-
| 'recipientOutput' // Replaced below
229-
>
230-
& {
228+
& Transform<BitcoinTransactionInfo, 'recipientOutput', {
231229
recipientOutput: Omit<BitcoinTransactionOutput,
232230
| 'address' // Only known in second step (in swap-iframe), derived from htlcScript
233231
| 'label' // Not used
234232
>,
235233
refundKeyPath: string, // To validate that we own the HTLC script's refund address
236-
}
234+
}>
237235
) | (
238236
{type: 'EUR'}
239237
& {

src/request/swap-iframe/SwapIFrameApi.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
327327
// Add change output
328328
if (storedRequest.fund.changeOutput) {
329329
// The address is set in SignSwap after password entry.
330+
if (!storedRequest.fund.changeOutput.address) {
331+
throw new Errors.KeyguardError('Missing address in funding change output');
332+
}
333+
330334
outputs.push(/** @type {{address: string, value: number}} */ (storedRequest.fund.changeOutput));
331335
}
332336

@@ -495,6 +499,9 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
495499
}];
496500

497501
// The address is set in SignSwap after password entry.
502+
if (!storedRequest.redeem.output.address) {
503+
throw new Errors.KeyguardError('Missing address in redeem output');
504+
}
498505
const output = /** @type {{address: string, value: number}} */ (storedRequest.redeem.output);
499506

500507
// Construct transaction

0 commit comments

Comments
 (0)