AddBogusOrchardSpends
This commit is contained in:
parent
d4b2ec6359
commit
dcc47bd882
|
@ -1260,8 +1260,6 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "orchard"
|
name = "orchard"
|
||||||
version = "0.1.0-beta.2"
|
version = "0.1.0-beta.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b48e6e124c3f7e9ed7f48b29f66069288235cecd16aa6053e98f8aff16efe827"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"arrayvec 0.7.2",
|
"arrayvec 0.7.2",
|
||||||
|
|
|
@ -87,6 +87,7 @@ codegen-units = 1
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
hdwallet = { git = "https://github.com/nuttycom/hdwallet", rev = "576683b9f2865f1118c309017ff36e01f84420c9" }
|
hdwallet = { git = "https://github.com/nuttycom/hdwallet", rev = "576683b9f2865f1118c309017ff36e01f84420c9" }
|
||||||
|
orchard = { path = "../orchard/" }
|
||||||
zcash_address = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
zcash_address = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
||||||
zcash_encoding = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
zcash_encoding = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
||||||
zcash_history = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
zcash_history = { git = "https://github.com/zcash/librustzcash.git", rev = "9c1ed86c5aa8ae3b6d6dcc1478f2d6ba1264488f" }
|
||||||
|
|
|
@ -42,6 +42,10 @@ OrchardBuilderPtr* orchard_builder_new(
|
||||||
/// Frees an Orchard builder returned from `orchard_builder_new`.
|
/// Frees an Orchard builder returned from `orchard_builder_new`.
|
||||||
void orchard_builder_free(OrchardBuilderPtr* ptr);
|
void orchard_builder_free(OrchardBuilderPtr* ptr);
|
||||||
|
|
||||||
|
bool orchard_builder_duplicate_nullifier_spend(
|
||||||
|
OrchardBuilderPtr* ptr
|
||||||
|
);
|
||||||
|
|
||||||
/// Adds a note to be spent in this bundle.
|
/// Adds a note to be spent in this bundle.
|
||||||
///
|
///
|
||||||
/// Returns `false` if the Merkle path in `spend_info` does not have the
|
/// Returns `false` if the Merkle path in `spend_info` does not have the
|
||||||
|
|
|
@ -66,6 +66,17 @@ pub extern "C" fn orchard_builder_new(
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn orchard_builder_duplicate_nullifier_spend(
|
||||||
|
builder: *mut Builder
|
||||||
|
) -> bool {
|
||||||
|
let builder = unsafe { builder.as_mut() }.expect("Builder may not be null.");
|
||||||
|
|
||||||
|
builder.add_duplicate_nullifier_spend(OsRng);
|
||||||
|
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn orchard_builder_add_spend(
|
pub extern "C" fn orchard_builder_add_spend(
|
||||||
builder: *mut Builder,
|
builder: *mut Builder,
|
||||||
|
|
|
@ -42,6 +42,16 @@ Builder::Builder(
|
||||||
inner.reset(orchard_builder_new(spendsEnabled, outputsEnabled, anchor.IsNull() ? nullptr : anchor.begin()));
|
inner.reset(orchard_builder_new(spendsEnabled, outputsEnabled, anchor.IsNull() ? nullptr : anchor.begin()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Builder::AddBogusSpends()
|
||||||
|
{
|
||||||
|
if (!inner) {
|
||||||
|
throw std::logic_error("orchard::Builder has already been used");
|
||||||
|
}
|
||||||
|
|
||||||
|
orchard_builder_duplicate_nullifier_spend(inner.get());
|
||||||
|
hasActions = true;
|
||||||
|
}
|
||||||
|
|
||||||
bool Builder::AddSpend(orchard::SpendInfo spendInfo)
|
bool Builder::AddSpend(orchard::SpendInfo spendInfo)
|
||||||
{
|
{
|
||||||
if (!inner) {
|
if (!inner) {
|
||||||
|
@ -292,6 +302,15 @@ bool TransactionBuilder::SupportsOrchard() const {
|
||||||
return orchardBuilder.has_value();
|
return orchardBuilder.has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TransactionBuilder::AddBogusOrchardSpends()
|
||||||
|
{
|
||||||
|
if (!orchardBuilder.has_value()) {
|
||||||
|
throw std::runtime_error("TransactionBuilder orchardBuilder not setup");
|
||||||
|
}
|
||||||
|
|
||||||
|
orchardBuilder.value().AddBogusSpends();
|
||||||
|
}
|
||||||
|
|
||||||
bool TransactionBuilder::AddOrchardSpend(
|
bool TransactionBuilder::AddOrchardSpend(
|
||||||
libzcash::OrchardSpendingKey sk,
|
libzcash::OrchardSpendingKey sk,
|
||||||
orchard::SpendInfo spendInfo)
|
orchard::SpendInfo spendInfo)
|
||||||
|
|
|
@ -101,6 +101,8 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AddBogusSpends();
|
||||||
|
|
||||||
/// Adds a note to be spent in this bundle.
|
/// Adds a note to be spent in this bundle.
|
||||||
///
|
///
|
||||||
/// Returns `false` if the given Merkle path does not have the required anchor
|
/// Returns `false` if the given Merkle path does not have the required anchor
|
||||||
|
@ -337,6 +339,8 @@ public:
|
||||||
|
|
||||||
bool SupportsOrchard() const;
|
bool SupportsOrchard() const;
|
||||||
|
|
||||||
|
void AddBogusOrchardSpends();
|
||||||
|
|
||||||
bool AddOrchardSpend(
|
bool AddOrchardSpend(
|
||||||
libzcash::OrchardSpendingKey sk,
|
libzcash::OrchardSpendingKey sk,
|
||||||
orchard::SpendInfo spendInfo);
|
orchard::SpendInfo spendInfo);
|
||||||
|
|
Loading…
Reference in New Issue