-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
34df5be
commit d45194b
Showing
11 changed files
with
121 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/app/features/ledger/flows/bitcoin-tx-signing/bitcoin-tx-signing-event-listeners.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as btc from '@scure/btc-signer'; | ||
|
||
import { GlobalAppEvents, appEvents } from '@app/common/publish-subscribe'; | ||
|
||
export async function listenForBitcoinTxLedgerSigning(psbt: string): Promise<btc.Transaction> { | ||
return new Promise((resolve, reject) => { | ||
function txSignedHandler(msg: GlobalAppEvents['ledgerBitcoinTxSigned']) { | ||
if (msg.unsignedPsbt === psbt) { | ||
appEvents.unsubscribe('ledgerBitcoinTxSigned', txSignedHandler); | ||
appEvents.unsubscribe('ledgerBitcoinTxSigningCancelled', signingAbortedHandler); | ||
resolve(msg.signedPsbt); | ||
} | ||
} | ||
appEvents.subscribe('ledgerBitcoinTxSigned', txSignedHandler); | ||
|
||
function signingAbortedHandler(msg: GlobalAppEvents['ledgerBitcoinTxSigningCancelled']) { | ||
if (msg.unsignedPsbt === psbt) { | ||
appEvents.unsubscribe('ledgerBitcoinTxSigningCancelled', signingAbortedHandler); | ||
appEvents.unsubscribe('ledgerBitcoinTxSigned', txSignedHandler); | ||
reject(new Error('User cancelled the signing operation')); | ||
} | ||
} | ||
appEvents.subscribe('ledgerBitcoinTxSigningCancelled', signingAbortedHandler); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.