Skip to content

Commit

Permalink
Merge pull request #838 from BoltzExchange/discount-ct-mainnet
Browse files Browse the repository at this point in the history
Discount CT on mainnet
  • Loading branch information
michael1011 authored Mar 4, 2025
2 parents 94692d3 + aa291b3 commit 098f6c8
Show file tree
Hide file tree
Showing 21 changed files with 208 additions and 422 deletions.
61 changes: 34 additions & 27 deletions boltzr/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 10 additions & 10 deletions boltzr/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ panic = "abort"
[dependencies]
axum = "0.8.1"
bitcoin_hashes = "0.16.0"
clap = { version = "4.5.30", features = ["derive"] }
clap = { version = "4.5.31", features = ["derive"] }
crossbeam-channel = "0.5.14"
ctrlc = { version = "3.4.5", features = ["termination"] }
dirs = "6.0.0"
Expand All @@ -44,7 +44,7 @@ prost = "0.13.5"
rcgen = { version = "0.13.2", features = ["x509-parser"] }
reqwest = { version = "0.12.12", features = ["json"] }
serde = { version = "1.0.218", features = ["derive"] }
serde_json = "1.0.139"
serde_json = "1.0.140"
tokio = { version = "1.43.0", features = [
"rt-multi-thread",
"macros",
Expand All @@ -65,7 +65,7 @@ axum-prometheus = { version = "0.6.1", default-features = false, optional = true
metrics = { version = "0.24.1", optional = true }
diesel_migrations = "2.2.0"
r2d2 = "0.8.10"
diesel = { version = "2.2.7", default-features = false, features = [
diesel = { version = "2.2.8", default-features = false, features = [
"postgres",
"r2d2",
"chrono",
Expand Down Expand Up @@ -105,10 +105,10 @@ async-tungstenite = { version = "0.29.1", features = [
"tokio-native-tls",
"tokio-runtime",
] }
async-trait = "0.1.86"
async-trait = "0.1.87"
futures-util = "0.3.31"
async-stream = "0.3.6"
anyhow = "1.0.96"
anyhow = "1.0.97"
lightning = { version = "0.1.1", features = ["std"] }
lightning-invoice = { version = "0.33.1", features = ["std"] }
bech32 = "0.9.1"
Expand All @@ -117,16 +117,16 @@ elements = "0.25.1"
base64 = "0.22.1"
rust-s3 = "0.35.1"
cron = "0.15.0"
chrono = "0.4.39"
chrono = "0.4.40"
fedimint-tonic-lnd = { version = "0.2.0", features = [
"lightningrpc",
], default-features = false }
flate2 = "1.0.35"
flate2 = "1.1.0"
pyroscope = { version = "0.5.8", optional = true }
pyroscope_pprofrs = { version = "0.2.8", optional = true }
csv = "1.3.1"
axum-extra = { version = "0.10.0", features = ["typed-header"] }
redis = { version = "0.29.0", features = ["tokio-comp", "r2d2"] }
redis = { version = "0.29.1", features = ["tokio-comp", "r2d2"] }
bytes = "1.10.0"
rust-bip39 = "1.0.0"
elements-miniscript = "0.4.0"
Expand All @@ -136,10 +136,10 @@ built = { version = "0.7.7", features = ["git2"] }
tonic-build = "0.12.3"

[dev-dependencies]
eventsource-client = "0.13.0"
eventsource-client = "0.14.0"
http-body-util = "0.1.2"
mockall = "0.13.1"
rand = "0.9.0"
rstest = "0.24.0"
rstest = "0.25.0"
serial_test = "3.2.0"
tower = { version = "0.5.2", features = ["util"] }
6 changes: 0 additions & 6 deletions docker/regtest/data/elements/elements.conf
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ con_nrulechangeactivationthreshold=1
## Taproot signaling
con_taproot_signal_start=0

# Lowball
mintxfee=0.0000001
fallbackfee=0.0000001
blockmintxfee=0.0000001
minrelaytxfee=0.00000009

# Discount CT
acceptdiscountct=1
creatediscountct=1
4 changes: 2 additions & 2 deletions lib/Core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ export const constructClaimTransaction = (
wallet.network as LiquidNetwork,
decodedAddress.blindingKey,
),
walletLiquid.supportsDiscountCT,
true,
);
});
} catch (e) {
Expand Down Expand Up @@ -355,7 +355,7 @@ export const constructRefundTransaction = (
wallet.network as LiquidNetwork,
decodedAddress.blindingKey,
),
walletLiquid.supportsDiscountCT,
true,
);
});
} catch (e) {
Expand Down
15 changes: 5 additions & 10 deletions lib/chain/ElementsClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
LiquidBalances,
liquidSymbol,
} from '../consts/LiquidTypes';
import type WalletLiquid from '../wallet/WalletLiquid';
import ChainClient, { AddressType, IChainClient } from './ChainClient';

enum LiquidAddressType {
Expand All @@ -30,32 +29,28 @@ class ElementsClient
implements IElementsClient
{
public static readonly symbol = liquidSymbol;

private static readonly minNoLowBallFee = 0.1;
private static readonly feeFloor = 0.1;

constructor(
logger: Logger,
config: ChainConfig,
public readonly isLowball = false,
) {
super(logger, config, ElementsClient.symbol);
this.feeFloor = ElementsClient.feeFloor;
this.currencyType = CurrencyType.Liquid;
this.feeFloor = isLowball ? 0.01 : ElementsClient.minNoLowBallFee;
}

public static needsLowball = (
wallet: WalletLiquid,
tx: Transaction,
): boolean => {
public static needsLowball = (tx: Transaction): boolean => {
const feeOutput = tx.outs.find((out) => out.script.length === 0);
if (feeOutput === undefined) {
return false;
}

return (
confidential.confidentialValueToSatoshi(feeOutput.value) /
tx.virtualSize(wallet.supportsDiscountCT) <
ElementsClient.minNoLowBallFee
tx.virtualSize(true) <
ElementsClient.feeFloor
);
};

Expand Down
5 changes: 0 additions & 5 deletions lib/cli/BuilderComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,4 @@ export default {
describe: 'preimage of the swap',
type: 'string',
},
discountCT: {
describe: 'whether discount CT should be used',
type: 'boolean',
default: false,
},
};
3 changes: 0 additions & 3 deletions lib/cli/Command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ export const prepareTx = async (
network,
argv.destinationAddress,
argv.blindingKey,
argv.discountCT,
),
destinationAddress: argv.destinationAddress,
keys: ECPair.fromPrivateKey(getHexBuffer(argv.privateKey)),
Expand Down Expand Up @@ -150,12 +149,10 @@ export const getWalletStub = (
network: Network | LiquidNetwork,
destinationAddress: string,
blindingKey?: string,
discountCT?: boolean,
) =>
({
type,
network,
supportsDiscountCT: discountCT || false,
decodeAddress: () => toOutputScript(type, destinationAddress, network),
deriveBlindingKeyFromScript: () => {
const key = {
Expand Down
3 changes: 1 addition & 2 deletions lib/cli/commands/Claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import BuilderComponents from '../BuilderComponents';
import { prepareTx } from '../Command';

export const command =
'claim <network> <preimage> <privateKey> <redeemScript> <rawTransaction> <destinationAddress> [feePerVbyte] [blindingKey] [discountCT]';
'claim <network> <preimage> <privateKey> <redeemScript> <rawTransaction> <destinationAddress> [feePerVbyte] [blindingKey]';

export const describe = 'claims reverse submarine or chain to chain swaps';

Expand All @@ -22,7 +22,6 @@ export const builder = {
destinationAddress: BuilderComponents.destinationAddress,
feePerVbyte: BuilderComponents.feePerVbyte,
blindingKey: BuilderComponents.blindingKey,
discountCT: BuilderComponents.discountCT,
};

export const handler = async (argv: Arguments<any>): Promise<void> => {
Expand Down
3 changes: 1 addition & 2 deletions lib/cli/commands/Refund.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import BuilderComponents from '../BuilderComponents';
import { prepareTx } from '../Command';

export const command =
'refund <network> <privateKey> <timeoutBlockHeight> <redeemScript> <rawTransaction> <destinationAddress> [feePerVbyte] [blindingKey] [discountCT]';
'refund <network> <privateKey> <timeoutBlockHeight> <redeemScript> <rawTransaction> <destinationAddress> [feePerVbyte] [blindingKey]';

export const describe = 'refunds submarine or chain to chain swaps';

Expand All @@ -25,7 +25,6 @@ export const builder = {
destinationAddress: BuilderComponents.destinationAddress,
feePerVbyte: BuilderComponents.feePerVbyte,
blindingKey: BuilderComponents.blindingKey,
discountCT: BuilderComponents.discountCT,
};

export const handler = async (argv: Arguments<any>): Promise<void> => {
Expand Down
Loading

0 comments on commit 098f6c8

Please sign in to comment.