Skip to content

Commit

Permalink
Merge branch 'master' into soeren/settlement-signing
Browse files Browse the repository at this point in the history
  • Loading branch information
sisou committed Nov 8, 2021
2 parents fc19f4d + 188f7be commit f17d97c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
8 changes: 3 additions & 5 deletions client/src/PublicRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type ObjectType = {

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

// Base types for Requests
export type BasicRequest = {
Expand Down Expand Up @@ -224,16 +225,13 @@ export type SignSwapRequestCommon = SimpleRequest & {
& { senderLabel: string }
) | (
{type: 'BTC'}
& Omit<BitcoinTransactionInfo,
| 'recipientOutput' // Replaced below
>
& {
& Transform<BitcoinTransactionInfo, 'recipientOutput', {
recipientOutput: Omit<BitcoinTransactionOutput,
| 'address' // Only known in second step (in swap-iframe), derived from htlcScript
| 'label' // Not used
>,
refundKeyPath: string, // To validate that we own the HTLC script's refund address
}
}>
) | (
{type: 'EUR'}
& {
Expand Down
7 changes: 7 additions & 0 deletions src/request/swap-iframe/SwapIFrameApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,10 @@ class SwapIFrameApi extends BitcoinRequestParserMixin(RequestParser) { // eslint
// Add change output
if (storedRequest.fund.changeOutput) {
// The address is set in SignSwap after password entry.
if (!storedRequest.fund.changeOutput.address) {
throw new Errors.KeyguardError('Missing address in funding change output');
}

outputs.push(/** @type {{address: string, value: number}} */ (storedRequest.fund.changeOutput));
}

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

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

// Construct transaction
Expand Down

0 comments on commit f17d97c

Please sign in to comment.