Class: Sigma::Wallet
- Inherits:
-
Object
- Object
- Sigma::Wallet
- Extended by:
- FFI::Library
- Defined in:
- lib/sigma/wallet.rb
Instance Attribute Summary collapse
-
#pointer ⇒ Object
Returns the value of attribute pointer.
Class Method Summary collapse
-
.create_from_mnemonic(mnemonic_phrase, mnemonic_pass) ⇒ Wallet
Create Wallet instance loading secret key from mnemonic.
-
.create_from_secrets(secrets) ⇒ Wallet
Create Wallet from secrets.
Instance Method Summary collapse
-
#add_secret(secret) ⇒ Object
Add a secret to the wallet’s prover.
-
#generate_commitments(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:) ⇒ TransactionHintsBag
Generate Commitments for unsigned tx.
-
#generate_commitments_for_reduced_transaction(reduced_tx) ⇒ TransactionHintsBag
Generate Commitments for reduced transaction.
-
#sign_reduced_transaction(reduced_tx) ⇒ Transaction
Signs a reduced transaction (generating proofs for inputs).
-
#sign_reduced_transaction_multi(reduced_tx:, tx_hints:) ⇒ Transaction
Signs a multi signature reduced transaction.
-
#sign_transaction(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:) ⇒ Transaction
Sign a transaction.
-
#sign_transaction_multi(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:, tx_hints:) ⇒ Transaction
Sign a multi-signature transaction.
Instance Attribute Details
#pointer ⇒ Object
Returns the value of attribute pointer.
20 21 22 |
# File 'lib/sigma/wallet.rb', line 20 def pointer @pointer end |
Class Method Details
.create_from_mnemonic(mnemonic_phrase, mnemonic_pass) ⇒ Wallet
Create Wallet instance loading secret key from mnemonic. Throws error if a DlogSecretKey cannot be parsed from the provided phrase
27 28 29 30 31 32 |
# File 'lib/sigma/wallet.rb', line 27 def self.create_from_mnemonic(mnemonic_phrase, mnemonic_pass) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_wallet_from_mnemonic(mnemonic_phrase, mnemonic_pass, pointer) Util.check_error!(error) init(pointer) end |
.create_from_secrets(secrets) ⇒ Wallet
Create Wallet from secrets
37 38 39 40 41 |
# File 'lib/sigma/wallet.rb', line 37 def self.create_from_secrets(secrets) pointer = FFI::MemoryPointer.new(:pointer) ergo_lib_wallet_from_secrets(secrets.pointer, pointer) init(pointer) end |
Instance Method Details
#add_secret(secret) ⇒ Object
Add a secret to the wallet’s prover
45 46 47 48 |
# File 'lib/sigma/wallet.rb', line 45 def add_secret(secret) error = ergo_lib_wallet_add_secret(self.pointer, secret.pointer) Util.check_error!(error) end |
#generate_commitments(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:) ⇒ TransactionHintsBag
Generate Commitments for unsigned tx
104 105 106 107 108 109 |
# File 'lib/sigma/wallet.rb', line 104 def generate_commitments(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_wallet_generate_commitments(self.pointer, state_context.pointer, unsigned_tx.pointer, boxes_to_spend.pointer, data_boxes.pointer, pointer) Util.check_error!(error) Sigma::TransactionHintsBag.with_raw_pointer(pointer) end |
#generate_commitments_for_reduced_transaction(reduced_tx) ⇒ TransactionHintsBag
Generate Commitments for reduced transaction
114 115 116 117 118 119 |
# File 'lib/sigma/wallet.rb', line 114 def generate_commitments_for_reduced_transaction(reduced_tx) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_wallet_generate_commitments_for_reduced_transaction(self.pointer, reduced_tx.pointer, pointer) Util.check_error!(error) Sigma::TransactionHintsBag.with_raw_pointer(pointer) end |
#sign_reduced_transaction(reduced_tx) ⇒ Transaction
Signs a reduced transaction (generating proofs for inputs)
80 81 82 83 84 85 |
# File 'lib/sigma/wallet.rb', line 80 def sign_reduced_transaction(reduced_tx) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_wallet_sign_reduced_transaction(self.pointer, reduced_tx.pointer, pointer) Util.check_error!(error) Sigma::Transaction.with_raw_pointer(pointer) end |
#sign_reduced_transaction_multi(reduced_tx:, tx_hints:) ⇒ Transaction
Signs a multi signature reduced transaction
91 92 93 94 95 96 |
# File 'lib/sigma/wallet.rb', line 91 def sign_reduced_transaction_multi(reduced_tx:, tx_hints:) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_wallet_sign_reduced_transaction_multi(self.pointer, reduced_tx.pointer, tx_hints.pointer, pointer) Util.check_error!(error) Sigma::Transaction.with_raw_pointer(pointer) end |
#sign_transaction(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:) ⇒ Transaction
Sign a transaction
56 57 58 59 60 61 |
# File 'lib/sigma/wallet.rb', line 56 def sign_transaction(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_wallet_sign_transaction(self.pointer, state_context.pointer, unsigned_tx.pointer, boxes_to_spend.pointer, data_boxes.pointer, pointer) Util.check_error!(error) Sigma::Transaction.with_raw_pointer(pointer) end |
#sign_transaction_multi(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:, tx_hints:) ⇒ Transaction
Sign a multi-signature transaction
70 71 72 73 74 75 |
# File 'lib/sigma/wallet.rb', line 70 def sign_transaction_multi(state_context:, unsigned_tx:, boxes_to_spend:, data_boxes:, tx_hints:) pointer = FFI::MemoryPointer.new(:pointer) error = ergo_lib_wallet_sign_transaction_multi(self.pointer, state_context.pointer, unsigned_tx.pointer, boxes_to_spend.pointer, data_boxes.pointer, tx_hints.pointer, pointer) Util.check_error!(error) Sigma::Transaction.with_raw_pointer(pointer) end |