Struct Signer

Source
pub struct Signer { /* private fields */ }

Implementations§

Source§

impl Signer

Source

pub fn new<T>( secret: Vec<u8>, network: Network, creds: T, ) -> Result<Signer, Error>

Source

pub async fn run_once(&self, node_uri: Uri) -> Result<(), Error>

Given the URI of the running node, connect to it and stream requests from it. The requests are then verified and processed using the Hsmd.

Source

pub fn node_id(&self) -> Vec<u8>

Source

pub fn get_init(&self) -> Vec<u8>

Source

pub fn get_startup_messages(&self) -> Vec<StartupMessage>

Retrieve the messages we know lightningd will ask when starting. Since we can’t be attached during startup, or on background sync runs, we need to stash them at the scheduler so we can start without a signer present.

Source

pub fn bip32_ext_key(&self) -> Vec<u8>

Source

pub fn legacy_bip32_ext_key(&self) -> Vec<u8>

Source

pub async fn run_forever(&self, shutdown: Receiver<()>) -> Result<(), Error>

Connect to the scheduler given by the environment variable GL_SCHEDULER_GRPC_URI (of the default URI) and wait for the node to be scheduled. Once scheduled, connect to the node directly and start streaming and processing requests.

Source

pub async fn run_forever_with_uri( &self, shutdown: Receiver<()>, scheduler_uri: String, ) -> Result<(), Error>

Source

pub fn sign_challenge(&self, challenge: Vec<u8>) -> Result<Vec<u8>, Error>

Source

pub fn sign_device_key(&self, key: &[u8]) -> Result<Vec<u8>, Error>

Signs the devices public key. This signature is meant to be appended to any payload signed by the device so that the signer can verify that it knows the device.

Source

pub fn sign_message(&self, msg: Vec<u8>) -> Result<(Vec<u8>, u8), Error>

Signs a message with the hsmd client. Returns a tuple with the signature and the unmodified recovery id.

Source

pub fn sign_invoice(&self, msg: Vec<u8>) -> Result<Vec<u8>, Error>

Signs an invoice.

Source

pub async fn node<Creds>(&self, creds: Creds) -> Result<Client, Error>

Create a Node stub from this instance of the signer, configured to talk to the corresponding node.

Source

pub fn version(&self) -> &'static str

Source

pub fn create_rune( &self, rune: Option<&str>, restrictions: Vec<Vec<&str>>, ) -> Result<String, Error>

Creates a base64 string called a rune which is used to authorize commands on the node and to issue signatures from the signer. Each new rune must contain a pubkey field that equals the public key that is used to sign-off signature requests. Nobody can remove restrictions from a rune.

If a rune is supplied the restrictions are added to this rune. This way one can invoke a rune that only allows for a subset of commands.

restrictions is a vector of restrictions where each restriction itself is a vector of one ore more alternatives.

  • =: passes if equal ie. identical. e.g. method=withdraw
  • /: not equals, e.g. method/withdraw
  • ^: starts with, e.g. id^024b9a1fa8e006f1e3937f
  • $: ends with, e.g. id$381df1cc449605.
  • ~: contains, e.g. id~006f1e3937f65f66c40.
  • <: is a decimal integer, and is less than. e.g. time<1656759180
  • >: is a decimal integer, and is greater than. e.g. time>1656759180
  • {: preceeds in alphabetical order (or matches but is shorter), e.g. id{02ff.
  • }: follows in alphabetical order (or matches but is longer), e.g. id}02ff.
  • #: a comment, ignored, e.g. dumb example#.
  • !: only passes if the name does not exist. e.g. something!. Every other operator except # fails if name does not exist!
§Examples

This creates a fresh rune that is only restricted to a pubkey:

create_rune(None, vec![vec!["pubkey=000000"]])

“wjEjvKoFJToMLBv4QVbJpSbMoGFlnYVxs8yy40PIBgs9MC1nbDAmcHVia2V5PTAwMDAwMA”

This adds a restriction to the rune, in this case a restriction that only allows to call methods that start with “list” or “get”, basically a read-only rune:

create_rune("wjEjvKoFJToMLBv4QVbJpSbMoGFlnYVxs8yy40PIBgs9MC1nbDAmcHVia2V5PTAwMDAwMA", vec![vec!["method^list", "method^get"]])

Trait Implementations§

Source§

impl Clone for Signer

Source§

fn clone(&self) -> Signer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl !Freeze for Signer

§

impl !RefUnwindSafe for Signer

§

impl Send for Signer

§

impl Sync for Signer

§

impl Unpin for Signer

§

impl !UnwindSafe for Signer

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Any for T
where T: Any,

Source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Source§

fn type_name(&self) -> &'static str

Source§

impl<T> AnySync for T
where T: Any + Send + Sync,

Source§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

fn type_name(&self) -> &'static str

Gets the type name of self
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast for T
where T: AsAny + ?Sized,

Source§

fn is<T>(&self) -> bool
where T: AsAny,

Returns true if the boxed type is the same as T. Read more
Source§

fn downcast_ref<T>(&self) -> Option<&T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

fn downcast_mut<T>(&mut self) -> Option<&mut T>
where T: AsAny,

Forward to the method defined on the type Any.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,