Skip to content
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
8b7e96e
provide metadata for nBTC
olga24912 Jul 3, 2025
5bffba6
fix satoshi bridge cargo toml
olga24912 Jul 3, 2025
21d3776
address -> script_pubkey
olga24912 Jul 8, 2025
a1db442
btc-p2wpkh -> utxo_chain
olga24912 Jul 8, 2025
b887eeb
remove btc_network
olga24912 Jul 8, 2025
7002936
draft zcash tx impl
olga24912 Jul 15, 2025
68883e2
fix consenses decode
olga24912 Jul 16, 2025
0f484cd
zcash_primitives
olga24912 Jul 16, 2025
5ebffa2
fix cargo toml
olga24912 Jul 16, 2025
2883749
test for script
olga24912 Jul 16, 2025
1f8932c
fix get output
olga24912 Jul 16, 2025
673da64
change signhash
olga24912 Jul 17, 2025
0307c59
Refactor transaction type
karim-en Jul 17, 2025
31a2e7f
Bump zcash_primitives version
karim-en Jul 17, 2025
6be07c5
Convert btc tx into zcash tx
karim-en Jul 18, 2025
0e96dd0
Set `final_script_sig`
karim-en Jul 18, 2025
527e439
Fix sighash
karim-en Jul 18, 2025
c78f4cf
fix
karim-en Jul 18, 2025
ff8d87a
fix sequence
olga24912 Jul 20, 2025
6a2f5e7
zcash build
olga24912 Jul 20, 2025
db2dc1d
add zcash features
olga24912 Jul 20, 2025
bdd78e5
AddressInner -> Address
olga24912 Jul 20, 2025
b6a54b2
new line
olga24912 Jul 20, 2025
c3cc9d9
test parse address
olga24912 Jul 20, 2025
15fa72b
test from pubkey
olga24912 Jul 21, 2025
dbbd678
improve tests
olga24912 Jul 21, 2025
e72188e
fix warnings
olga24912 Jul 21, 2025
d1f47ff
check zcash fee
olga24912 Jul 22, 2025
b467c49
safe expiry height
olga24912 Jul 23, 2025
15e0bd1
fix expiry_height
olga24912 Jul 23, 2025
31633fd
add rbf
olga24912 Jul 24, 2025
2f7cca2
fix sequence
olga24912 Jul 24, 2025
986564b
extract expire_height for cancel_withdraw
olga24912 Jul 24, 2025
ec69040
fix cancel active utxo managment
olga24912 Jul 24, 2025
1b124ca
fix active utxo managment
olga24912 Jul 24, 2025
cb67c3d
utxo_mamagment extract block height
olga24912 Jul 25, 2025
725f5bc
gap into config
olga24912 Jul 25, 2025
8380486
Replace last_block_header with last_block_height
karim-en Jul 30, 2025
dc4136d
construct output for zcash
olga24912 Aug 6, 2025
8caa61c
add simple try from address
olga24912 Aug 6, 2025
d471465
parse unified address
olga24912 Aug 6, 2025
dcf242c
script pubkey
olga24912 Aug 6, 2025
28bb108
fmt for unified address
olga24912 Aug 6, 2025
b1871d8
fix find receiver in list
olga24912 Aug 7, 2025
bda96c5
fix warnings
olga24912 Aug 8, 2025
b7531b0
safe psbt wraper
olga24912 Aug 8, 2025
36dcef4
deserialize
olga24912 Aug 8, 2025
c351bdf
move het hash to sign
olga24912 Aug 8, 2025
08cca99
extract tx byte
olga24912 Aug 8, 2025
86d3d76
save signature
olga24912 Aug 8, 2025
7d8601c
incapsulate psbt
olga24912 Aug 8, 2025
f5a2b2d
separate transaction
olga24912 Aug 11, 2025
b2d1eeb
separate expiry hight
olga24912 Aug 11, 2025
e6424da
separate psbt creation
olga24912 Aug 11, 2025
03b98ba
separate chain specific functions
olga24912 Aug 11, 2025
23c6dcd
separate zcash functions
olga24912 Aug 11, 2025
a292d73
separate zcash
olga24912 Aug 11, 2025
35f0f3c
fix btc
olga24912 Aug 11, 2025
54515e4
fix warnings
olga24912 Aug 11, 2025
1fffdc4
optimize get min fee
olga24912 Aug 12, 2025
4374342
remove psbt for zcash
olga24912 Aug 12, 2025
2a7c2dd
remove unsed function
olga24912 Aug 12, 2025
a69a203
add get_input_num and get_output_num
olga24912 Aug 12, 2025
91accdf
fix satoshi bridge
olga24912 Aug 12, 2025
d643f47
fix new
olga24912 Aug 12, 2025
f3638d0
make psbt field private
olga24912 Aug 13, 2025
a7fed6d
reduce copy past
olga24912 Aug 13, 2025
d629183
reduce copypast
olga24912 Aug 13, 2025
9429bb4
fix test contract config for zcash
olga24912 Aug 13, 2025
7ad9489
don't panic
olga24912 Aug 13, 2025
e93e376
fmt
olga24912 Aug 13, 2025
57762bd
reduce include
olga24912 Aug 13, 2025
4344a0e
updaye zcash_protocol
olga24912 Aug 13, 2025
0c7595f
fix chain id
olga24912 Aug 13, 2025
0182643
remove default
olga24912 Aug 13, 2025
68c072c
add version
olga24912 Aug 14, 2025
3482f1a
fix bitcoin connector
olga24912 Aug 14, 2025
8087bbb
remove bytes_to_btc_transaction
olga24912 Aug 18, 2025
5ec8b1d
don't use fully-qualified name
olga24912 Aug 18, 2025
d3bfdb1
fix bitcoin tests
olga24912 Aug 20, 2025
f1250b7
fix check block heigth for branch id
olga24912 Aug 20, 2025
f4ca9b9
save block height
olga24912 Aug 21, 2025
ca251c7
fix
olga24912 Aug 21, 2025
cbe475b
fix make
olga24912 Aug 21, 2025
4a3d3e5
fix valid confiramtions range
olga24912 Aug 21, 2025
f3103dd
Bump version
karim-en Aug 21, 2025
641d411
fix: use `U128` type for amount in `ft_on_transfer_callback`
frolvanya Aug 22, 2025
7e9057a
provide max gas fee
olga24912 Aug 28, 2025
3100dfa
Merge branch 'omni-main' into zcash_support
olga24912 Sep 5, 2025
e778abc
Add orchard support
karim-en Sep 12, 2025
2c4dc0a
Add comments
karim-en Sep 15, 2025
852f39f
Add comment
karim-en Sep 15, 2025
c8114f5
fix outputs checks
olga24912 Sep 29, 2025
945f087
Calculate sighash with `orchard_bundle`
karim-en Nov 19, 2025
43475c5
Implement Orchard Bundle Validation for Zcash Withdrawals (#20)
r-near Jan 6, 2026
3612052
Avoid extra clone of Orchard bundle
karim-en Jan 6, 2026
0be10b6
Replace panic with panic_str
karim-en Jan 7, 2026
95cd8ef
Bump version
karim-en Jan 7, 2026
0e88488
Fix clippy
karim-en Jan 7, 2026
2a7d703
Fix build variant
karim-en Jan 7, 2026
2960fb9
Fix orchard tests
karim-en Jan 7, 2026
c4341aa
Run lint and tests to CI
karim-en Jan 7, 2026
b347aef
Merge branch 'omni-main' into orchard_tx
karim-en Jan 7, 2026
2f0a2b8
Revert default
karim-en Jan 7, 2026
4db11cf
Remove added ci
karim-en Jan 7, 2026
ac14727
Remove unused fmt
karim-en Jan 7, 2026
089cc58
Fix tests
karim-en Jan 7, 2026
c9ec7e4
Fix orchard test
karim-en Jan 7, 2026
39f3c17
Fix orchard test
karim-en Jan 7, 2026
561e38e
Add missed `safe_deposit`
karim-en Jan 7, 2026
a80df03
add different wasm path
olga24912 Jan 8, 2026
cf0a130
fix orchard tests
olga24912 Jan 8, 2026
56f7687
fix test_base
olga24912 Jan 8, 2026
70dd014
fix check predecessor account id
olga24912 Jan 9, 2026
a07ebe1
fix test
olga24912 Jan 9, 2026
c43a72c
fix check outputs number
olga24912 Jan 12, 2026
629a189
unwrap -> expect
olga24912 Jan 12, 2026
dd4487c
extract expiry height check
olga24912 Jan 12, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,885 changes: 1,477 additions & 408 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
.PHONY: zcash-bridge

RFLAGS="-C link-arg=-s"

build: lint satoshi-bridge nbtc mock-chain-signatures mock-btc-light-client mock-dapp
build: lint satoshi-bridge zcash-bridge nbtc mock-chain-signatures mock-btc-light-client mock-dapp

lint:
@cargo fmt --all
Expand All @@ -9,6 +11,9 @@ lint:
satoshi-bridge: contracts/satoshi-bridge
$(call local_build_wasm,satoshi-bridge,satoshi_bridge)

zcash-bridge: contracts/satoshi-bridge
$(call local_build_zcash_wasm)

nbtc: contracts/nbtc
$(call local_build_wasm,nbtc,nbtc)

Expand All @@ -28,6 +33,7 @@ count:
release:
$(call build_release_wasm,satoshi-bridge,satoshi_bridge)
$(call build_release_wasm,nbtc,nbtc)
$(call build_release_zcash_wasm)

clean:
cargo clean
Expand All @@ -51,4 +57,18 @@ define build_release_wasm
@rustup target add wasm32-unknown-unknown
@cargo near build reproducible-wasm --manifest-path ./contracts/${PACKAGE_NAME}/Cargo.toml
@cp target/near/${WASM_NAME}/$(WASM_NAME).wasm ./res/$(WASM_NAME)_release.wasm
endef
endef

define build_release_zcash_wasm
@mkdir -p res
@rustup target add wasm32-unknown-unknown
@cargo near build reproducible-wasm --manifest-path ./contracts/satoshi-bridge/Cargo.toml --variant zcash
@cp target/near/satoshi_bridge/satoshi_bridge.wasm ./res/zcash_connector_release.wasm
endef

define local_build_zcash_wasm
@mkdir -p res
@rustup target add wasm32-unknown-unknown
@cargo near build non-reproducible-wasm --manifest-path ./contracts/satoshi-bridge/Cargo.toml --locked --no-abi --no-default-features --features zcash
@cp target/near/satoshi_bridge/satoshi_bridge.wasm ./res/zcash.wasm
endef
5 changes: 5 additions & 0 deletions contracts/mock-btc-light-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,9 @@ impl Contract {
pub fn verify_transaction_inclusion(&self, #[serializer(borsh)] args: ProofArgs) -> bool {
true
}

pub fn get_last_block_height(&self) -> u32 {
// Return a reasonable mock block height for Zcash testnet
1000
}
}
2 changes: 1 addition & 1 deletion contracts/nbtc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "nbtc"
version = "0.1.0"
version = "0.2.0"
edition.workspace = true
publish.workspace = true
repository.workspace = true
Expand Down
19 changes: 12 additions & 7 deletions contracts/nbtc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ pub struct Contract {
metadata: LazyOption<FungibleTokenMetadata>,
}

const DATA_IMAGE_SVG_NEAR_ICON: &str = "data:image/svg+xml,%3Csvg%20width%3D%2232%22%20height%3D%2232%22%20viewBox%3D%220%200%2032%2032%22%20fill%3D%22none%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cg%20clip-path%3D%22url(%23clip0_2351_779)%22%3E%3Cpath%20d%3D%22M16%2032C24.8366%2032%2032%2024.8366%2032%2016C32%207.16344%2024.8366%200%2016%200C7.16344%200%200%207.16344%200%2016C0%2024.8366%207.16344%2032%2016%2032Z%22%20fill%3D%22%2300E99F%22%2F%3E%3Cpath%20d%3D%22M16.0006%2028.2858C22.7858%2028.2858%2028.2863%2022.7853%2028.2863%2016.0001C28.2863%209.21486%2022.7858%203.71436%2016.0006%203.71436C9.21535%203.71436%203.71484%209.21486%203.71484%2016.0001C3.71484%2022.7853%209.21535%2028.2858%2016.0006%2028.2858Z%22%20stroke%3D%22black%22%2F%3E%3Cpath%20d%3D%22M27.1412%2016C27.1412%2022.1541%2022.1524%2027.1429%2015.9983%2027.1429C9.84427%2027.1429%204.85547%2022.1541%204.85547%2016C4.85547%209.84598%209.84427%204.85718%2015.9983%204.85718C22.1524%204.85718%2027.1412%209.84598%2027.1412%2016Z%22%20stroke%3D%22black%22%20stroke-width%3D%220.5%22%2F%3E%3Cpath%20fill-rule%3D%22evenodd%22%20clip-rule%3D%22evenodd%22%20d%3D%22M16.2167%2011.1743C15.9198%2011.1643%2015.6095%2011.1622%2015.2868%2011.1668V9.32056H13.8907V11.2217C13.1583%2011.2659%2012.3792%2011.3332%2011.5625%2011.4149V12.811H12.9586V18.8607H11.7952V20.4895H13.8893V22.5836H15.2854V20.4895H16.2161V22.5836H17.3795V20.4895C18.4654%2020.4119%2020.6836%2019.7915%2020.8698%2017.93C21.0559%2016.0686%2019.7064%2015.6032%2019.0083%2015.6032C19.5512%2015.3705%2020.544%2014.5328%2020.1717%2013.0436C19.9215%2012.043%2019.0072%2011.5204%2017.6128%2011.2984V9.32164H16.2167V11.1743ZM18.0737%2013.9723C18.0737%2012.8554%2016.2122%2012.7313%2015.2815%2012.8088V15.1356C16.2122%2015.2132%2018.0737%2015.0891%2018.0737%2013.9723ZM15.2826%2016.5322V18.8591C16.2133%2018.9366%2018.3075%2018.859%2018.3075%2017.6956C18.3075%2016.2994%2016.2133%2016.4547%2015.2826%2016.5322Z%22%20fill%3D%22black%22%2F%3E%3C%2Fg%3E%3Cdefs%3E%3CclipPath%20id%3D%22clip0_2351_779%22%3E%3Crect%20width%3D%2232%22%20height%3D%2232%22%20fill%3D%22white%22%2F%3E%3C%2FclipPath%3E%3C%2Fdefs%3E%3C%2Fsvg%3E";

const GAS_FOR_RESOLVE_TRANSFER: Gas = Gas::from_tgas(5);
const GAS_FOR_FT_TRANSFER_CALL: Gas = Gas::from_tgas(30);

Expand All @@ -53,7 +51,14 @@ pub struct PostAction {
#[near]
impl Contract {
#[init]
pub fn new(controller: AccountId, bridge_id: AccountId) -> Self {
pub fn new(
controller: AccountId,
bridge_id: AccountId,
name: String,
symbol: String,
icon: Option<String>,
decimals: u8,
) -> Self {
require!(!env::state_exists(), "Already initialized");
Self {
controller,
Expand All @@ -63,12 +68,12 @@ impl Contract {
StorageKey::Metadata,
Some(&FungibleTokenMetadata {
spec: FT_METADATA_SPEC.to_string(),
name: "Near WTC".to_string(),
symbol: "NBTC".to_string(),
icon: Some(DATA_IMAGE_SVG_NEAR_ICON.to_string()),
name,
symbol,
icon,
reference: None,
reference_hash: None,
decimals: 8,
decimals,
}),
),
}
Expand Down
33 changes: 30 additions & 3 deletions contracts/satoshi-bridge/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "satoshi-bridge"
version = "0.5.1"
version = "0.6.0"
edition.workspace = true
publish.workspace = true
repository.workspace = true
Expand All @@ -21,19 +21,46 @@ container_build_command = [
"--no-abi",
]

[package.metadata.near.reproducible_build.variant.zcash]
container_build_command = [
"cargo",
"near",
"build",
"non-reproducible-wasm",
"--locked",
"--no-abi",
"--no-default-features",
"--features",
"zcash"
]

[dependencies]
near-sdk.workspace = true
near-contract-standards.workspace = true
bitcoin.workspace = true
hex.workspace = true
near-plugins.workspace = true
k256 = "0.13.1"
ed25519-dalek="2.1.0"
crypto-shared = { git = "https://github.com/near/mpc_old", rev = "0afee9004a1b1c3386940e60c28cff7cf1b5978c"}
ed25519-dalek = "2.1.0"
crypto-shared = { git = "https://github.com/near/mpc_old", rev = "0afee9004a1b1c3386940e60c28cff7cf1b5978c" }
zcash_primitives = { version = "0.24.0", default-features = false, features = ["circuits", "transparent-inputs"], optional = true }
zcash_transparent = { version = "0.4.0", features = ["transparent-inputs"], optional = true }
orchard = { version = "0.11.0", default-features = false, optional = true }
sapling-crypto = { version = "0.5.0", default-features = false, optional = true }
zcash_protocol = { version = "0.6.1" }
core2 = { version = "0.3", optional = true }
zcash_address = { version = "0.9.0" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2.12", features = ["custom"] }

[dev-dependencies]
near-workspaces = { version = "0.20", features = ["unstable"] }
tokio = { version = "1.12.0", features = ["full"] }
rand = "0.8"
hex = "0.4"
bs58 = "0.5"

[features]
default = []
zcash = ["zcash_primitives", "zcash_transparent", "orchard", "core2", "sapling-crypto"]
4 changes: 2 additions & 2 deletions contracts/satoshi-bridge/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ impl Contract {
.accounts
.get(account_id)
.map(|o| o.into())
.expect("ACCOUNT NOT REGISTERED")
.unwrap_or_else(|| panic!("ERR_ACCOUNT_NOT_REGISTERED: {}", account_id))
}

pub fn internal_unwrap_mut_account(&mut self, account_id: &AccountId) -> &mut Account {
self.data_mut()
.accounts
.get_mut(account_id)
.map(|o| o.into())
.expect("ACCOUNT NOT REGISTERED")
.unwrap_or_else(|| panic!("ERR_ACCOUNT_NOT_REGISTERED: {}", account_id))
}

pub fn internal_unwrap_or_create_mut_account(
Expand Down
Loading