pub struct Signer { /* private fields */ }
Implementations§
Source§impl Signer
impl Signer
pub fn new<T>(
secret: Vec<u8>,
network: Network,
creds: T,
) -> Result<Signer, Error>where
T: TlsConfigProvider,
Sourcepub async fn run_once(&self, node_uri: Uri) -> Result<(), Error>
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
.
pub fn node_id(&self) -> Vec<u8> ⓘ
pub fn get_init(&self) -> Vec<u8> ⓘ
Sourcepub fn get_startup_messages(&self) -> Vec<StartupMessage>
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.
pub fn bip32_ext_key(&self) -> Vec<u8> ⓘ
pub fn legacy_bip32_ext_key(&self) -> Vec<u8> ⓘ
Sourcepub async fn run_forever(&self, shutdown: Receiver<()>) -> Result<(), Error>
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.
pub async fn run_forever_with_uri( &self, shutdown: Receiver<()>, scheduler_uri: String, ) -> Result<(), Error>
pub fn sign_challenge(&self, challenge: Vec<u8>) -> Result<Vec<u8>, Error>
Sourcepub fn sign_device_key(&self, key: &[u8]) -> Result<Vec<u8>, Error>
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.
Sourcepub fn sign_message(&self, msg: Vec<u8>) -> Result<(Vec<u8>, u8), Error>
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.
Sourcepub async fn node<Creds>(&self, creds: Creds) -> Result<Client, Error>where
Creds: TlsConfigProvider + RuneProvider,
pub async fn node<Creds>(&self, creds: Creds) -> Result<Client, Error>where
Creds: TlsConfigProvider + RuneProvider,
Create a Node stub from this instance of the signer, configured to talk to the corresponding node.
pub fn version(&self) -> &'static str
Sourcepub fn create_rune(
&self,
rune: Option<&str>,
restrictions: Vec<Vec<&str>>,
) -> Result<String, Error>
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§
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<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for T
impl<T> Downcast for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request