Skip to content

Commit f614cf2

Browse files
aoenginceyhunsen
andauthored
Rename "claim_address" to "destination_address" (#119)
* Rename claim_address to destination_address for clarity in deposit and withdrawal commands * fmt * change all "claim"s to "destination" for clarity * typo --------- Co-authored-by: Ceyhun Şen <ceyhuusen@gmail.com>
1 parent c992918 commit f614cf2

File tree

8 files changed

+91
-80
lines changed

8 files changed

+91
-80
lines changed

docs/deposit.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ The deposit process consists of several stages:
2727
4. **Recovery (if needed)** - Recover funds if bridging fails
2828

2929
> [!IMPORTANT]
30-
> The `RECOVERY_TAPROOT_ADDRESS` and the `DEPOSIT_ADDRESS` are different. The `RECOVERY_TAPROOT_ADDRESS` will belong to your Clementine wallet to be able to perform deposit specific signing operations in case the deposit fails, whereas the `DEPOSIT_ADDRESS` is the address you send Bitcoin to in order to perform the deposit operation. Your `RECOVERY_TAPROOT_ADDRESS` is used alongside the `N_of_N_ADDRESS` when creating the `DEPOSIT_ADDRESS` to make sure if the deposit fails, you can recover your funds back to your `CLAIM_ADDRESS`.
30+
> The `RECOVERY_TAPROOT_ADDRESS` and the `DEPOSIT_ADDRESS` are different. The `RECOVERY_TAPROOT_ADDRESS` will belong to your Clementine wallet to be able to perform deposit specific signing operations in case the deposit fails, whereas the `DEPOSIT_ADDRESS` is the address you send Bitcoin to in order to perform the deposit operation. Your `RECOVERY_TAPROOT_ADDRESS` is used alongside the `N_of_N_ADDRESS` when creating the `DEPOSIT_ADDRESS` to make sure if the deposit fails, you can recover your funds back to your `DESTINATION_ADDRESS`.
3131
3232
## Step 1: Generate Deposit Address
3333

@@ -101,14 +101,14 @@ Gather all necessary information on your online device:
101101
- `RECOVERY_TAPROOT_ADDRESS`: Your wallet's recovery address (from airgapped device)
102102
- `EVM_ADDRESS`: Your Citrea address used for the deposit
103103
- `DEPOSIT_UTXO_OUTPOINT`: Your deposit Outpoint (`txid:vout`)
104-
- `CLAIM_ADDRESS`: Bitcoin address where recovered funds will be sent
104+
- `DESTINATION_ADDRESS`: Bitcoin address where recovered funds will be sent
105105

106106
### Create Recovery Transaction (Airgapped Device)
107107

108108
**AIRGAPPED DEVICE ONLY:** Transfer recovery data to airgapped device and generate signed recovery transaction:
109109

110110
```sh
111-
clementine-cli deposit create-signed-recovery-tx --network <BITCOIN_NETWORK> <RECOVERY_TAPROOT_ADDRESS> <CITREA_ADDRESS> <DEPOSIT_OUTPOINT> <CLAIM_ADDRESS> <FEE_RATE> <AMOUNT>
111+
clementine-cli deposit create-signed-recovery-tx --network <BITCOIN_NETWORK> <RECOVERY_TAPROOT_ADDRESS> <CITREA_ADDRESS> <DEPOSIT_OUTPOINT> <DESTINATION_ADDRESS> <FEE_RATE> <AMOUNT>
112112
```
113113

114114
**Example:**

docs/withdraw.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ All available withdrawal commands can be viewed using `clementine-cli withdraw -
99
Before starting a withdrawal, ensure you have:
1010

1111
- A Clementine wallet with `withdrawal` purpose ("wit" prefix address)
12-
- A Bitcoin address where funds will be sent (claim address)
12+
- A Bitcoin address where funds will be sent (destination address)
1313
- Access to both airgapped and online devices
1414
- Sufficient balance on Citrea to withdraw
1515

@@ -27,20 +27,20 @@ The withdrawal process follows these sequential steps:
2727
8. **Check Status** - Monitor withdrawal progress for operator-paid withdrawal
2828

2929
> [!IMPORTANT]
30-
> The `SIGNER_ADDRESS` and the `CLAIM_ADDRESS` are different. The `SIGNER_ADDRESS` will belong to your Clementine wallet to be able to perform withdrawal specific signing operations, whereas `CLAIM_ADDRESS` is the address that the withdrawn BTC funds will be sent to.
30+
> The `SIGNER_ADDRESS` and the `DESTINATION_ADDRESS` are different. The `SIGNER_ADDRESS` will belong to your Clementine wallet to be able to perform withdrawal specific signing operations, whereas `DESTINATION_ADDRESS` is the address that the withdrawn BTC funds will be sent to.
3131
3232
## Step 1: Start Withdrawal
3333

3434
**ONLINE DEVICE OPERATION:** Start the withdrawal process:
3535

3636
```sh
37-
clementine-cli withdraw start --network <BITCOIN_NETWORK> <SIGNER_ADDRESS> <CLAIM_ADDRESS>
37+
clementine-cli withdraw start --network <BITCOIN_NETWORK> <SIGNER_ADDRESS> <DESTINATION_ADDRESS>
3838
```
3939

4040
**Parameters:**
4141

4242
- `SIGNER_ADDRESS`: Withdrawal wallet address with "wit" prefix (from airgapped device)
43-
- `CLAIM_ADDRESS`: Bitcoin address where funds will be sent
43+
- `DESTINATION_ADDRESS`: Bitcoin address where funds will be sent
4444

4545
**Example:**
4646

@@ -76,7 +76,7 @@ This creates the 0-value UTXO needed for the withdrawal operation.
7676
**ONLINE DEVICE OPERATION:** Scan for available withdrawal UTXOs that can be used for the withdrawal operation:
7777

7878
```sh
79-
clementine-cli withdraw scan --network <BITCOIN_NETWORK> <SIGNER_ADDRESS> <CLAIM_ADDRESS>
79+
clementine-cli withdraw scan --network <BITCOIN_NETWORK> <SIGNER_ADDRESS> <DESTINATION_ADDRESS>
8080
```
8181

8282
**Example:**
@@ -96,7 +96,7 @@ This command will scan Bitcoin network and return possible withdrawal scenarios
9696
**Transfer from online device to airgapped device:**
9797

9898
- Signer address (with "wit" prefix)
99-
- Withdrawal address (claim address)
99+
- Withdrawal address (destination address)
100100
- Withdrawal UTXO details (from scan command)
101101

102102
### Generate Signature
@@ -191,7 +191,7 @@ clementine-cli withdraw send-withdrawal-signature-to-operators --network testne
191191
**Critical Security Requirements:**
192192

193193
- **Airgapped Signing**: ALL signature generation must occur on airgapped device
194-
- **Address Verification**: Always verify withdrawal and claim addresses before signing
194+
- **Address Verification**: Always verify withdrawal and destination addresses before signing
195195
- **Signature Protection**: Never share or expose withdrawal signatures
196196
- **Data Verification**: Cross-check all parameters between devices
197197
- **Status Monitoring**: Regularly monitor withdrawal progress

src/bitcoin_utils.rs

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ fn sign_with_tweak(
7979
}
8080

8181
#[allow(clippy::too_many_arguments)]
82-
/// Sign a recovery transaction with a given keypair, Citrea address, recovery taproot address, deposit outpoint, deposit amount, claim address, fee rate, and network
82+
/// Sign a recovery transaction with a given keypair, Citrea address, recovery taproot address, deposit outpoint, deposit amount, destination address, fee rate, and network
8383
pub(crate) fn sign_recovery_tx(
8484
keypair: &SecureKeypair,
8585
citrea_address: &CitreaAddress,
8686
recovery_taproot_address: &BitcoinAddress,
8787
deposit_outpoint: &OutPoint,
8888
deposit_amount: Amount,
89-
claim_address: &BitcoinAddress,
89+
destination_address: &BitcoinAddress,
9090
fee_rate: FeeRate,
9191
config: &BridgeCliConfig,
9292
) -> Result<Transaction, BridgeCliError> {
@@ -110,7 +110,7 @@ pub(crate) fn sign_recovery_tx(
110110

111111
let txout = TxOut {
112112
value: deposit_amount,
113-
script_pubkey: claim_address.script_pubkey(),
113+
script_pubkey: destination_address.script_pubkey(),
114114
};
115115

116116
let mut recovery_tx = Transaction {
@@ -122,8 +122,8 @@ pub(crate) fn sign_recovery_tx(
122122

123123
// This is the weight of the transaction without script_pubkey.
124124
let mut weight = Weight::from_wu(414);
125-
let claim_address_script_len = claim_address.script_pubkey().to_bytes().len();
126-
weight += Weight::from_wu(claim_address_script_len as u64 * 4);
125+
let destination_address_script_len = destination_address.script_pubkey().to_bytes().len();
126+
weight += Weight::from_wu(destination_address_script_len as u64 * 4);
127127
let fee = fee_rate.fee_wu(weight).expect("fee is valid");
128128
let output_amount: Amount = match deposit_amount.checked_sub(fee) {
129129
Some(amt) => amt,
@@ -315,10 +315,10 @@ pub(crate) fn sign_withdrawal_signature(
315315
keypair: &SecureKeypair,
316316
signer_address: &BitcoinAddress,
317317
withdrawal_utxo: &OutPoint,
318-
claim_address: &BitcoinAddress,
318+
destination_address: &BitcoinAddress,
319319
amount: Amount,
320320
) -> Result<bitcoin::taproot::Signature, BridgeCliError> {
321-
let withdrawal_tx = create_withdrawal_transaction(withdrawal_utxo, claim_address, amount);
321+
let withdrawal_tx = create_withdrawal_transaction(withdrawal_utxo, destination_address, amount);
322322
let prevout = create_withdrawal_prevout(signer_address);
323323

324324
let sighash = create_withdrawal_sighash(&withdrawal_tx, &prevout)?;
@@ -332,7 +332,7 @@ pub(crate) fn sign_withdrawal_signature(
332332

333333
fn create_withdrawal_transaction(
334334
withdrawal_utxo: &OutPoint,
335-
claim_address: &BitcoinAddress,
335+
destination_address: &BitcoinAddress,
336336
amount: Amount,
337337
) -> Transaction {
338338
let txin = TxIn {
@@ -344,7 +344,7 @@ fn create_withdrawal_transaction(
344344

345345
let txout = TxOut {
346346
value: amount,
347-
script_pubkey: claim_address.script_pubkey(),
347+
script_pubkey: destination_address.script_pubkey(),
348348
};
349349

350350
Transaction {
@@ -359,10 +359,10 @@ pub(crate) fn verify_withdrawal_signature(
359359
sig: &bitcoin::taproot::Signature,
360360
signer_address: &BitcoinAddress,
361361
withdrawal_utxo: &OutPoint,
362-
claim_address: &BitcoinAddress,
362+
destination_address: &BitcoinAddress,
363363
amount: Amount,
364364
) -> Result<(), BridgeCliError> {
365-
let withdrawal_tx = create_withdrawal_transaction(withdrawal_utxo, claim_address, amount);
365+
let withdrawal_tx = create_withdrawal_transaction(withdrawal_utxo, destination_address, amount);
366366
let prevout = create_withdrawal_prevout(signer_address);
367367

368368
let sighash = create_withdrawal_sighash(&withdrawal_tx, &prevout)?;
@@ -512,36 +512,37 @@ mod tests {
512512
}
513513
}
514514

515-
fn create_claim_address(
515+
fn create_destination_address(
516516
address_type: AddressType,
517517
network: Network,
518518
key_offset: u8,
519519
) -> BitcoinAddress {
520520
use bitcoin::key::{CompressedPublicKey, PublicKey};
521521
use bitcoin::script::Builder;
522522

523-
let claim_secret = SecretKey::from_slice(&[key_offset; 32]).unwrap();
524-
let claim_keypair = Keypair::from_secret_key(&SECP, &claim_secret);
525-
let claim_pubkey = PublicKey::from(claim_keypair.public_key());
526-
let claim_compressed_pubkey = CompressedPublicKey::try_from(claim_pubkey).unwrap();
523+
let destination_secret = SecretKey::from_slice(&[key_offset; 32]).unwrap();
524+
let destination_keypair = Keypair::from_secret_key(&SECP, &destination_secret);
525+
let destination_pubkey = PublicKey::from(destination_keypair.public_key());
526+
let destination_compressed_pubkey =
527+
CompressedPublicKey::try_from(destination_pubkey).unwrap();
527528

528529
match address_type {
529530
AddressType::P2tr => {
530-
let secure_keypair = SecureKeypair::new(claim_keypair);
531+
let secure_keypair = SecureKeypair::new(destination_keypair);
531532
calculate_taproot_address(&secure_keypair, network)
532533
}
533-
AddressType::P2wpkh => BitcoinAddress::p2wpkh(&claim_compressed_pubkey, network),
534-
AddressType::P2pkh => BitcoinAddress::p2pkh(claim_compressed_pubkey, network),
534+
AddressType::P2wpkh => BitcoinAddress::p2wpkh(&destination_compressed_pubkey, network),
535+
AddressType::P2pkh => BitcoinAddress::p2pkh(destination_compressed_pubkey, network),
535536
AddressType::P2sh => {
536-
let claim_redeem_script = Builder::new()
537+
let destination_redeem_script = Builder::new()
537538
.push_int(0)
538-
.push_slice(claim_compressed_pubkey.pubkey_hash())
539+
.push_slice(destination_compressed_pubkey.pubkey_hash())
539540
.into_script();
540-
BitcoinAddress::p2sh(&claim_redeem_script, network).unwrap()
541+
BitcoinAddress::p2sh(&destination_redeem_script, network).unwrap()
541542
}
542543
AddressType::P2wsh => {
543544
let witness_script = Builder::new()
544-
.push_slice(claim_compressed_pubkey.to_bytes())
545+
.push_slice(destination_compressed_pubkey.to_bytes())
545546
.push_opcode(bitcoin::opcodes::all::OP_CHECKSIG)
546547
.into_script();
547548
BitcoinAddress::p2wsh(&witness_script, network)
@@ -598,7 +599,8 @@ mod tests {
598599

599600
fn test_fee_rate_correctness_for_address_type(address_type: AddressType, key_offset: u8) {
600601
let setup = TestSetup::new();
601-
let claim_address = create_claim_address(address_type, setup.config.network, key_offset);
602+
let destination_address =
603+
create_destination_address(address_type, setup.config.network, key_offset);
602604

603605
for fee_rate in get_test_fee_rates() {
604606
let result = sign_recovery_tx(
@@ -607,7 +609,7 @@ mod tests {
607609
&setup.recovery_address,
608610
&setup.deposit_outpoint,
609611
setup.deposit_amount,
610-
&claim_address,
612+
&destination_address,
611613
fee_rate,
612614
&setup.config,
613615
);

src/cli.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ pub async fn deposit_create_signed_recovery_tx(
285285
citrea_addr: &CitreaAddress,
286286
recovery_taproot_address: &TaprootAddressWithPrefix<bitcoin::address::NetworkChecked>,
287287
outpoint: &OutPoint,
288-
claim_addr: &BitcoinAddress,
288+
destination_addr: &BitcoinAddress,
289289
fee_rate: u64,
290290
amount: f64,
291291
config: &BridgeCliConfig,
@@ -298,7 +298,7 @@ pub async fn deposit_create_signed_recovery_tx(
298298
citrea_addr: *citrea_addr,
299299
recovery_taproot_address: recovery_taproot_address.clone(),
300300
outpoint: *outpoint,
301-
claim_addr: claim_addr.clone(),
301+
destination_addr: destination_addr.clone(),
302302
fee_rate: Some(fee_rate),
303303
amount: Some(amount),
304304
};
@@ -401,19 +401,19 @@ pub async fn cli_get_deposit_address(
401401

402402
pub async fn cli_start_withdrawal(
403403
signer_address: &TaprootAddressWithPrefix<bitcoin::address::NetworkChecked>,
404-
claim_address: &BitcoinAddress,
404+
destination_address: &BitcoinAddress,
405405
config: &BridgeCliConfig,
406406
) -> Result<(), BridgeCliError> {
407-
start_withdrawal(signer_address, claim_address, config)?;
407+
start_withdrawal(signer_address, destination_address, config)?;
408408
Ok(())
409409
}
410410

411411
pub async fn cli_scan_withdrawals(
412412
signer_address: &TaprootAddressWithPrefix<bitcoin::address::NetworkChecked>,
413-
claim_address: &BitcoinAddress,
413+
destination_address: &BitcoinAddress,
414414
config: &BridgeCliConfig,
415415
) -> Result<(), BridgeCliError> {
416-
let utxos = withdraw::scan_withdrawal(signer_address, claim_address, config).await;
416+
let utxos = withdraw::scan_withdrawal(signer_address, destination_address, config).await;
417417

418418
let mut utxos =
419419
utxos.inspect_err(|e| eprintln!("{} Failed to scan withdrawals: {}", "ERROR".bold(), e))?;
@@ -455,7 +455,7 @@ pub async fn cli_scan_withdrawals(
455455
"clementine-cli withdraw generate-withdrawal-signatures --network {} {} {} {}",
456456
config.network,
457457
&signer_address.address_with_prefix(),
458-
claim_address,
458+
destination_address,
459459
outpoint,
460460
);
461461
};
@@ -494,7 +494,7 @@ pub async fn cli_scan_withdrawals(
494494

495495
pub fn cli_generate_withdrawal_signatures(
496496
signer_address: &TaprootAddressWithPrefix<bitcoin::address::NetworkChecked>,
497-
claim_address: &BitcoinAddress,
497+
destination_address: &BitcoinAddress,
498498
withdrawal_utxo: &OutPoint,
499499
optimistic_withdrawal_amount: &Amount,
500500
operator_withdrawal_amount: &Amount,
@@ -508,7 +508,7 @@ pub fn cli_generate_withdrawal_signatures(
508508
generate_withdrawal_signatures(
509509
keypair,
510510
signer_address,
511-
claim_address,
511+
destination_address,
512512
withdrawal_utxo,
513513
optimistic_withdrawal_amount,
514514
operator_withdrawal_amount,

src/deposit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub struct RecoveryTxParams {
1919
pub citrea_addr: CitreaAddress,
2020
pub recovery_taproot_address: TaprootAddressWithPrefix<bitcoin::address::NetworkChecked>,
2121
pub outpoint: OutPoint,
22-
pub claim_addr: BitcoinAddress,
22+
pub destination_addr: BitcoinAddress,
2323
pub fee_rate: Option<u64>,
2424
pub amount: Option<f64>,
2525
}
@@ -148,7 +148,7 @@ pub fn create_signed_recovery_tx(
148148
&params.recovery_taproot_address.address,
149149
&params.outpoint,
150150
deposit_amount.unwrap_or(config.bridge_amount),
151-
&params.claim_addr,
151+
&params.destination_addr,
152152
fee_rate,
153153
config,
154154
)?;

src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ pub enum BridgeCliError {
147147
#[error("Address mismatch! The decrypted key doesn't correspond to this wallet address.")]
148148
AddressMismatch,
149149
#[error(
150-
"Claim address cannot be a wallet address. The claim address belongs to one of your wallets."
150+
"Destination address cannot be a wallet address. The destination address belongs to one of your wallets."
151151
)]
152-
ClaimAddressIsWalletAddress,
152+
DestinationAddressIsWalletAddress,
153153
#[error("Address '{0}' should not have a prefix.")]
154154
AddressShouldNotHavePrefix(String),
155155

0 commit comments

Comments
 (0)