no-std support for monero-serai (#311)

* Move monero-serai from std to std-shims, where possible

* no-std fixes

* Make the HttpRpc its own feature, thiserror only on std

* Drop monero-rs's epee for a homegrown one

We only need it for a single function. While I tried jeffro's, it didn't work
out of the box, had three unimplemented!s, and is no where near viable for
no_std.

Fixes #182, though should be further tested.

* no-std monero-serai

* Allow base58-monero via git

* cargo fmt
This commit is contained in:
Luke Parker
2023-06-29 04:14:29 -04:00
committed by GitHub
parent d25c668ee4
commit ac708b3b2a
30 changed files with 487 additions and 261 deletions

View File

@@ -1,7 +1,9 @@
use core::{ops::Deref, fmt};
use std::io;
use thiserror::Error;
use std_shims::{
vec::Vec,
io,
string::{String, ToString},
};
use rand_core::{RngCore, CryptoRng, SeedableRng};
use rand_chacha::ChaCha20Rng;
@@ -42,7 +44,9 @@ use crate::{
},
};
#[cfg(feature = "std")]
mod builder;
#[cfg(feature = "std")]
pub use builder::SignableTransactionBuilder;
#[cfg(feature = "multisig")]
@@ -116,34 +120,35 @@ impl SendOutput {
}
}
#[derive(Clone, PartialEq, Eq, Debug, Error)]
#[derive(Clone, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
pub enum TransactionError {
#[error("multiple addresses with payment IDs")]
#[cfg_attr(feature = "std", error("multiple addresses with payment IDs"))]
MultiplePaymentIds,
#[error("no inputs")]
#[cfg_attr(feature = "std", error("no inputs"))]
NoInputs,
#[error("no outputs")]
#[cfg_attr(feature = "std", error("no outputs"))]
NoOutputs,
#[error("only one output and no change address")]
#[cfg_attr(feature = "std", error("only one output and no change address"))]
NoChange,
#[error("too many outputs")]
#[cfg_attr(feature = "std", error("too many outputs"))]
TooManyOutputs,
#[error("too much data")]
#[cfg_attr(feature = "std", error("too much data"))]
TooMuchData,
#[error("too many inputs/too much arbitrary data")]
#[cfg_attr(feature = "std", error("too many inputs/too much arbitrary data"))]
TooLargeTransaction,
#[error("not enough funds (in {0}, out {1})")]
#[cfg_attr(feature = "std", error("not enough funds (in {0}, out {1})"))]
NotEnoughFunds(u64, u64),
#[error("wrong spend private key")]
#[cfg_attr(feature = "std", error("wrong spend private key"))]
WrongPrivateKey,
#[error("rpc error ({0})")]
#[cfg_attr(feature = "std", error("rpc error ({0})"))]
RpcError(RpcError),
#[error("clsag error ({0})")]
#[cfg_attr(feature = "std", error("clsag error ({0})"))]
ClsagError(ClsagError),
#[error("invalid transaction ({0})")]
#[cfg_attr(feature = "std", error("invalid transaction ({0})"))]
InvalidTransaction(RpcError),
#[cfg(feature = "multisig")]
#[error("frost error {0}")]
#[cfg_attr(feature = "std", error("frost error {0}"))]
FrostError(FrostError),
}