Skip to content

Commit f968214

Browse files
authored
Merge pull request #2218 from zcash/zcb-improve-warning
zcash_client_backend: Improve `store_decrypted_tx` unsupported `TxOut` warning
2 parents 43bd42b + 9f95dd2 commit f968214

9 files changed

Lines changed: 75 additions & 15 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ crypto-common = { version = "=0.2.0-rc.1" } # later RCs require edition2024
7878
ripemd = { version = "0.1", default-features = false }
7979
secp256k1 = { version = "0.29", default-features = false, features = ["alloc"] }
8080
transparent = { package = "zcash_transparent", version = "0.6.2", path = "zcash_transparent", default-features = false }
81-
zcash_script = { version = "0.4.2", default-features = false }
81+
zcash_script = { version = "0.4.3", default-features = false }
8282
zeroize = { version = "1.7", default-features = false }
8383

8484
# Boilerplate & missing stdlib

supply-chain/audits.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1870,6 +1870,11 @@ criteria = "safe-to-deploy"
18701870
delta = "0.15.0 -> 0.16.0"
18711871
notes = "This release involves only updates of previously-vetted dependencies."
18721872

1873+
[[audits.zcash_script]]
1874+
who = "Jack Grigg <thestr4d@gmail.com>"
1875+
criteria = "safe-to-deploy"
1876+
delta = "0.4.2 -> 0.4.3"
1877+
18731878
[[audits.zerocopy]]
18741879
who = "Daira-Emma Hopwood <daira@jacaranda.org>"
18751880
criteria = "safe-to-deploy"

supply-chain/config.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -579,10 +579,6 @@ criteria = "safe-to-deploy"
579579
version = "0.2.11"
580580
criteria = "safe-to-deploy"
581581

582-
[[exemptions.getrandom]]
583-
version = "0.3.4"
584-
criteria = "safe-to-deploy"
585-
586582
[[exemptions.getset]]
587583
version = "0.1.6"
588584
criteria = "safe-to-deploy"

supply-chain/imports.lock

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2228,6 +2228,11 @@ who = "David Cook <dcook@divviup.org>"
22282228
criteria = "safe-to-deploy"
22292229
delta = "0.2.14 -> 0.2.15"
22302230

2231+
[[audits.isrg.audits.getrandom]]
2232+
who = "David Cook <dcook@divviup.org>"
2233+
criteria = "safe-to-deploy"
2234+
delta = "0.3.3 -> 0.3.4"
2235+
22312236
[[audits.isrg.audits.hmac]]
22322237
who = "David Cook <dcook@divviup.org>"
22332238
criteria = "safe-to-deploy"
@@ -2751,6 +2756,31 @@ criteria = "safe-to-deploy"
27512756
delta = "0.3.27 -> 0.3.28"
27522757
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"
27532758

2759+
[[audits.mozilla.audits.getrandom]]
2760+
who = "Chris Martin <cmartin@mozilla.com>"
2761+
criteria = "safe-to-deploy"
2762+
delta = "0.2.15 -> 0.3.1"
2763+
notes = """
2764+
I've looked over all unsafe code, and it appears to be safe, fully initializing the rng buffers.
2765+
In addition, I've checked Linux, Windows, Mac, and Android more thoroughly against API
2766+
documentation.
2767+
"""
2768+
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"
2769+
2770+
[[audits.mozilla.audits.getrandom]]
2771+
who = "Emilio Cobos Álvarez <emilio@crisal.io>"
2772+
criteria = "safe-to-deploy"
2773+
delta = "0.3.1 -> 0.3.3"
2774+
notes = """
2775+
Biggest non-trivial change is a new UEFI back-end, which looks reasonable to
2776+
the best of my ability: There's some trickiness on initialization but doesn't
2777+
look unsafe, at worse it leaks, and it might not if the relevant pointers are
2778+
static/non-owning. Other changes also look reasonable too: some tweaks to
2779+
inlining and a syscall-based linux back-end, whose relevant unsafe code looks
2780+
reasonable.
2781+
"""
2782+
aggregated-from = "https://hg.mozilla.org/mozilla-central/raw-file/tip/supply-chain/audits.toml"
2783+
27542784
[[audits.mozilla.audits.hashbrown]]
27552785
who = "Mike Hommey <mh+mozilla@glandium.org>"
27562786
criteria = "safe-to-deploy"

zcash_client_backend/src/data_api/ll/wallet.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use tracing::{debug, info, trace, warn};
88

99
use incrementalmerkletree::{Marking, Position, Retention};
1010
use shardtree::error::ShardTreeError;
11+
use transparent::address::TransparentAddress;
1112
use zcash_keys::{address::Receiver, encoding::AddressCodec as _};
1213
use zcash_primitives::transaction::Transaction;
1314
use zcash_protocol::{
@@ -983,7 +984,11 @@ where
983984
.flat_map(|b| b.vout.iter())
984985
.enumerate()
985986
{
986-
if let Some(address) = txout.recipient_address() {
987+
let script_kind = txout.script_kind();
988+
if let Some(address) = script_kind
989+
.as_ref()
990+
.and_then(TransparentAddress::from_script_kind)
991+
{
987992
debug!(
988993
"{:?} output {} has recipient {}",
989994
d_tx.tx().txid(),
@@ -1046,6 +1051,13 @@ where
10461051
value: txout.value(),
10471052
});
10481053
}
1054+
} else if let Some(script_kind) = script_kind {
1055+
warn!(
1056+
"Ignoring unsupported script kind '{}' for tx {} output {}",
1057+
script_kind.as_str(),
1058+
d_tx.tx().txid(),
1059+
output_index
1060+
);
10491061
} else {
10501062
warn!(
10511063
"Unable to determine recipient address for tx {} output {}",

zcash_transparent/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ workspace.
1111
## [0.7.0] - PENDING
1212

1313
### Added
14+
- `zcash_transparent::address::TransparentAddress::from_script_kind`
15+
- `zcash_transparent::bundle::TxOut::script_kind`
1416
- `zcash_transparent::pczt`:
1517
- `Input::with_signable_input`
1618
- `Input::append_signature`

zcash_transparent/src/address.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,20 @@ impl TransparentAddress {
150150

151151
/// Returns the address that this Script contains, if any.
152152
pub fn from_script_pubkey(script_pubkey: &script::PubKey) -> Option<Self> {
153-
solver::standard(script_pubkey).and_then(|script_kind| match script_kind {
153+
solver::standard(script_pubkey)
154+
.as_ref()
155+
.and_then(Self::from_script_kind)
156+
}
157+
158+
/// Returns the address that this `ScriptKind` contains, if any.
159+
pub fn from_script_kind(script_kind: &solver::ScriptKind) -> Option<Self> {
160+
match script_kind {
154161
solver::ScriptKind::PubKeyHash { hash } => {
155-
Some(TransparentAddress::PublicKeyHash(hash))
162+
Some(TransparentAddress::PublicKeyHash(*hash))
156163
}
157-
solver::ScriptKind::ScriptHash { hash } => Some(TransparentAddress::ScriptHash(hash)),
164+
solver::ScriptKind::ScriptHash { hash } => Some(TransparentAddress::ScriptHash(*hash)),
158165
_ => None,
159-
})
166+
}
160167
}
161168

162169
/// Generate the `scriptPubKey` corresponding to this address.

zcash_transparent/src/bundle.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use zcash_script::{
88
pattern::push_num,
99
pv,
1010
script::{self, Evaluable as _},
11+
solver,
1112
};
1213

1314
use zcash_protocol::{
@@ -397,10 +398,9 @@ impl TxOut {
397398

398399
/// Returns the address to which the TxOut was sent, if this is a valid P2SH or P2PKH output.
399400
pub fn recipient_address(&self) -> Option<TransparentAddress> {
400-
script::PubKey::parse(&self.script_pubkey.0)
401-
.ok()
401+
self.script_kind()
402402
.as_ref()
403-
.and_then(TransparentAddress::from_script_pubkey)
403+
.and_then(TransparentAddress::from_script_kind)
404404
}
405405

406406
pub fn value(&self) -> Zatoshis {
@@ -410,6 +410,14 @@ impl TxOut {
410410
pub fn script_pubkey(&self) -> &Script {
411411
&self.script_pubkey
412412
}
413+
414+
/// Returns the kind of script to which the TxOut was sent, if this is a valid output.
415+
pub fn script_kind(&self) -> Option<solver::ScriptKind> {
416+
script::PubKey::parse(&self.script_pubkey.0)
417+
.ok()
418+
.as_ref()
419+
.and_then(solver::standard)
420+
}
413421
}
414422

415423
#[cfg(any(test, feature = "test-dependencies"))]

0 commit comments

Comments
 (0)