Skip to content

Commit fb308a1

Browse files
committed
Use alloc for no_std builds
Replace std structs with alloc equivalents to support no_std builds
1 parent 5d74cae commit fb308a1

34 files changed

+58
-5
lines changed

lightning/src/chain/chainmonitor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use util::logger::Logger;
3737
use util::events;
3838
use util::events::Event;
3939

40+
use alloc::vec::Vec;
4041
use std::collections::{HashMap, hash_map};
4142
use std::sync::RwLock;
4243
use std::ops::Deref;

lightning/src/chain/channelmonitor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ use util::ser::{Readable, ReadableArgs, MaybeReadable, Writer, Writeable, U48};
5151
use util::byte_utils;
5252
use util::events::Event;
5353

54+
use alloc::{vec, vec::Vec};
5455
use std::collections::{HashMap, HashSet};
5556
use std::{cmp, mem};
5657
use std::io::Error;
@@ -3060,6 +3061,7 @@ mod tests {
30603061
use bitcoin::secp256k1::Secp256k1;
30613062
use std::sync::{Arc, Mutex};
30623063
use chain::keysinterface::InMemorySigner;
3064+
use alloc::{vec, vec::Vec};
30633065

30643066
#[test]
30653067
fn test_prune_preimages() {

lightning/src/chain/keysinterface.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ use ln::chan_utils;
3737
use ln::chan_utils::{HTLCOutputInCommitment, make_funding_redeemscript, ChannelPublicKeys, HolderCommitmentTransaction, ChannelTransactionParameters, CommitmentTransaction};
3838
use ln::msgs::UnsignedChannelAnnouncement;
3939

40+
use alloc::vec::Vec;
4041
use std::collections::HashSet;
4142
use std::sync::atomic::{AtomicUsize, Ordering};
4243
use std::io::Error;

lightning/src/chain/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitor
1818
use chain::keysinterface::Sign;
1919
use chain::transaction::{OutPoint, TransactionData};
2020

21+
use alloc::vec::Vec;
22+
2123
pub mod chaininterface;
2224
pub mod chainmonitor;
2325
pub mod channelmonitor;

lightning/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#![cfg_attr(all(any(test, feature = "_test_utils"), feature = "unstable"), feature(test))]
3232
#[cfg(all(any(test, feature = "_test_utils"), feature = "unstable"))] extern crate test;
3333

34+
extern crate alloc;
3435
extern crate bitcoin;
3536
#[cfg(any(test, feature = "_test_utils"))] extern crate hex;
3637
#[cfg(any(test, feature = "fuzztarget", feature = "_test_utils"))] extern crate regex;

lightning/src/ln/chan_utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use bitcoin::secp256k1::{Secp256k1, Signature, Message};
3131
use bitcoin::secp256k1::Error as SecpError;
3232
use bitcoin::secp256k1;
3333

34+
use alloc::vec::Vec;
3435
use std::cmp;
3536
use ln::chan_utils;
3637
use util::transaction_utils::sort_outputs;
@@ -1235,6 +1236,7 @@ fn script_for_p2wpkh(key: &PublicKey) -> Script {
12351236
mod tests {
12361237
use super::CounterpartyCommitmentSecrets;
12371238
use hex;
1239+
use alloc::vec::Vec;
12381240

12391241
#[test]
12401242
fn test_per_commitment_storage() {

lightning/src/ln/chanmon_update_fail_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ use ln::functional_test_utils::*;
3737

3838
use util::test_utils;
3939

40+
use alloc::{vec, vec::Vec};
41+
4042
// If persister_fail is true, we have the persister return a PermanentFailure
4143
// instead of the higher-level ChainMonitor.
4244
fn do_test_simple_monitor_permanent_update_fail(persister_fail: bool) {

lightning/src/ln/channel.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use util::errors::APIError;
3939
use util::config::{UserConfig,ChannelConfig};
4040
use util::scid_utils::scid_from_parts;
4141

42+
use alloc::{string::String, vec, vec::Vec};
4243
use std;
4344
use std::{cmp,mem,fmt};
4445
use std::ops::Deref;
@@ -4878,6 +4879,7 @@ mod tests {
48784879
use bitcoin::hashes::Hash;
48794880
use bitcoin::hash_types::{Txid, WPubkeyHash};
48804881
use std::sync::Arc;
4882+
use alloc::{vec, vec::Vec};
48814883

48824884
struct TestFeeEstimator {
48834885
fee_est: u32

lightning/src/ln/channelmanager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use util::chacha20::{ChaCha20, ChaChaReader};
6161
use util::logger::Logger;
6262
use util::errors::APIError;
6363

64+
use alloc::{string::String, vec::Vec};
6465
use std::{cmp, mem};
6566
use std::collections::{HashMap, hash_map, HashSet};
6667
use std::io::{Cursor, Read};

lightning/src/ln/features.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
//! [BOLT #9]: https://github.com/lightningnetwork/lightning-rfc/blob/master/09-features.md
2323
//! [messages]: crate::ln::msgs
2424
25+
use alloc::vec::Vec;
2526
use std::{cmp, fmt};
2627
use std::marker::PhantomData;
2728

@@ -31,6 +32,7 @@ use ln::msgs::DecodeError;
3132
use util::ser::{Readable, Writeable, Writer};
3233

3334
mod sealed {
35+
use alloc::vec::Vec;
3436
use ln::features::Features;
3537

3638
/// The context in which [`Features`] are applicable. Defines which features are required and

0 commit comments

Comments
 (0)