File tree Expand file tree Collapse file tree
integration/blockchain/clementine
subdomains/core/liquidity-management/adapters/actions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ export enum DepositStatus {
2929}
3030
3131export enum WithdrawStatus {
32+ NOT_FOUND = 'not_found' ,
3233 PENDING = 'pending' ,
3334 SCANNING = 'scanning' ,
3435 SIGNING = 'signing' ,
@@ -314,9 +315,20 @@ export class ClementineClient {
314315 * Get the status of a withdrawal operation
315316 * Command: clementine-cli withdraw status <WITHDRAWAL_UTXO>
316317 * @param withdrawalUtxo The withdrawal UTXO to check (format: txid:vout)
318+ * @returns Status result with NOT_FOUND if no withdrawal exists for this UTXO
317319 */
318320 async withdrawStatus ( withdrawalUtxo : string ) : Promise < WithdrawStatusResult > {
319321 const output = await this . executeCommand ( [ 'withdraw' , 'status' , withdrawalUtxo ] ) ;
322+
323+ // Check if no withdrawal exists for this UTXO
324+ // CLI outputs "No withdrawals found for OutPoint ..." if never submitted
325+ if ( output . toLowerCase ( ) . includes ( 'no withdrawals found' ) ) {
326+ return {
327+ withdrawalUtxo,
328+ status : WithdrawStatus . NOT_FOUND ,
329+ } ;
330+ }
331+
320332 return this . parseWithdrawStatus ( output , withdrawalUtxo ) ;
321333 }
322334
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import {
1313 CLEMENTINE_WITHDRAWAL_DUST_BTC ,
1414 ClementineClient ,
1515 ClementineNetwork ,
16+ WithdrawStatus ,
1617} from 'src/integration/blockchain/clementine/clementine-client' ;
1718import { ClementineService } from 'src/integration/blockchain/clementine/clementine.service' ;
1819import { Blockchain } from 'src/integration/blockchain/shared/enums/blockchain.enum' ;
@@ -406,7 +407,10 @@ export class ClementineBridgeAdapter extends LiquidityActionAdapter {
406407 // This prevents double cBTC burning if the process crashes after withdrawSend()
407408 // but before the correlationId is persisted
408409 const existingStatus = await this . clementineClient . withdrawStatus ( data . withdrawalUtxo ) ;
409- if ( existingStatus . status !== 'pending' && existingStatus . status !== 'failed' ) {
410+
411+ // Only proceed with withdrawSend() if NO withdrawal exists for this UTXO
412+ // If status is anything other than NOT_FOUND, the withdrawal was already submitted
413+ if ( existingStatus . status !== WithdrawStatus . NOT_FOUND ) {
410414 this . logger . info (
411415 `Withdrawal: already submitted to bridge (status: ${ existingStatus . status } ), skipping withdrawSend()` ,
412416 ) ;
You can’t perform that action at this time.
0 commit comments