glueby 0.4.0 → 0.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,136 +1,141 @@
1
- module Glueby
2
- class FeeProvider
3
- class Tasks
4
- attr_reader :fee_provider
5
-
6
- STATUS = {
7
- # FeeProvider is ready to pay fees.
8
- ready: 'Ready',
9
- # FeeProvider is ready to pay fees, but it doesn't have enough amount to fill the UTXO pool by UTXOs which is for paying fees.
10
- insufficient_amount: 'Insufficient Amount',
11
- # FeeProvider is not ready to pay fees. It has no UTXOs for paying fee and amounts.
12
- not_ready: 'Not Ready'
13
- }
14
-
15
- def initialize
16
- @fee_provider = Glueby::FeeProvider.new
17
- end
18
-
19
- # Create UTXOs for paying fee from TPC amount of the wallet FeeProvider has. Then show the status.
20
- #
21
- # About the UTXO Pool
22
- # FeeProvider have the UTXO pool. the pool is manged to keep some number of UTXOs that have fixed fee value. The
23
- # value is configurable by :fixed_fee. This method do the management to the pool.
24
- def manage_utxo_pool
25
- txb = Tapyrus::TxBuilder.new
26
-
27
- sum, utxos = collect_outputs
28
- return if utxos.empty?
29
-
30
- utxos.each { |utxo| txb.add_utxo(utxo) }
31
- address = wallet.receive_address
32
-
33
- shortage = [fee_provider.utxo_pool_size - current_utxo_pool_size, 0].max
34
- can_create = (sum - fee_provider.fixed_fee) / fee_provider.fixed_fee
35
- fee_outputs_count_to_be_created = [shortage, can_create].min
36
-
37
- return if fee_outputs_count_to_be_created == 0
38
-
39
- fee_outputs_count_to_be_created.times do
40
- txb.pay(address, fee_provider.fixed_fee)
41
- end
42
-
43
- tx = txb.change_address(address)
44
- .fee(fee_provider.fixed_fee)
45
- .build
46
- tx = wallet.sign_tx(tx)
47
- wallet.broadcast(tx)
48
- ensure
49
- status
50
- end
51
-
52
- # Show the status of the UTXO pool
53
- def status
54
- status = :ready
55
-
56
- if current_utxo_pool_size < fee_provider.utxo_pool_size
57
- if tpc_amount < value_to_fill_utxo_pool
58
- status = :insufficient_amount
59
- message = <<~MESSAGE
60
- 1. Please replenishment TPC which is for paying fee to FeeProvider.
61
- FeeProvider needs #{value_to_fill_utxo_pool} tapyrus at least for paying 20 transaction fees.
62
- FeeProvider wallet's address is '#{wallet.receive_address}'
63
- 2. Then create UTXOs for paying in UTXO pool with 'rake glueby:fee_provider:manage_utxo_pool'
64
- MESSAGE
65
- else
66
- message = "Please create UTXOs for paying in UTXO pool with 'rake glueby:fee_provider:manage_utxo_pool'\n"
67
- end
68
- end
69
-
70
- status = :not_ready if current_utxo_pool_size == 0
71
-
72
- puts <<~EOS
73
- Status: #{STATUS[status]}
74
- TPC amount: #{delimit(tpc_amount)}
75
- UTXO pool size: #{delimit(current_utxo_pool_size)}
76
- #{"\n" if message}#{message}
77
- Configuration:
78
- fixed_fee = #{delimit(fee_provider.fixed_fee)}
79
- utxo_pool_size = #{delimit(fee_provider.utxo_pool_size)}
80
- EOS
81
- end
82
-
83
- private
84
-
85
- def check_wallet_amount!
86
- if tpc_amount < fee_provider.fixed_fee
87
- raise InsufficientTPC, <<~MESSAGE
88
- FeeProvider has insufficient TPC to create fee outputs to fill the UTXO pool.
89
- 1. Please replenishment TPC which is for paying fee to FeeProvider. FeeProvider needs #{fee_provider.utxo_pool_size * fee_provider.fixed_fee} tapyrus at least. FeeProvider wallet's address is '#{wallet.receive_address}'
90
- 2. Then create UTXOs for paying in UTXO pool with 'rake glueby:fee_provider:manage_utxo_pool'
91
- MESSAGE
92
- end
93
- end
94
-
95
- def tpc_amount
96
- wallet.balance(false)
97
- end
98
-
99
- def collect_outputs
100
- wallet.list_unspent.inject([0, []]) do |sum, output|
101
- next sum if output[:color_id] || output[:amount] == fee_provider.fixed_fee
102
-
103
- new_sum = sum[0] + output[:amount]
104
- new_outputs = sum[1] << {
105
- txid: output[:txid],
106
- script_pubkey: output[:script_pubkey],
107
- value: output[:amount],
108
- index: output[:vout] ,
109
- finalized: output[:finalized]
110
- }
111
- return [new_sum, new_outputs] if new_sum >= value_to_fill_utxo_pool
112
-
113
- [new_sum, new_outputs]
114
- end
115
- end
116
-
117
- def current_utxo_pool_size
118
- wallet
119
- .list_unspent(false)
120
- .count { |o| !o[:color_id] && o[:amount] == fee_provider.fixed_fee }
121
- end
122
-
123
- def value_to_fill_utxo_pool
124
- fee_provider.fixed_fee * (fee_provider.utxo_pool_size + 1) # +1 is for paying fee
125
- end
126
-
127
- def wallet
128
- fee_provider.wallet
129
- end
130
-
131
- def delimit(num)
132
- num.to_s.reverse.scan(/.{1,3}/).join('_').reverse
133
- end
134
- end
135
- end
1
+ module Glueby
2
+ class FeeProvider
3
+ class Tasks
4
+ attr_reader :fee_provider
5
+
6
+ STATUS = {
7
+ # FeeProvider is ready to pay fees.
8
+ ready: 'Ready',
9
+ # FeeProvider is ready to pay fees, but it doesn't have enough amount to fill the UTXO pool by UTXOs which is for paying fees.
10
+ insufficient_amount: 'Insufficient Amount',
11
+ # FeeProvider is not ready to pay fees. It has no UTXOs for paying fee and amounts.
12
+ not_ready: 'Not Ready'
13
+ }
14
+
15
+ def initialize
16
+ @fee_provider = Glueby::FeeProvider.new
17
+ end
18
+
19
+ # Create UTXOs for paying fee from TPC amount of the wallet FeeProvider has. Then show the status.
20
+ #
21
+ # About the UTXO Pool
22
+ # FeeProvider have the UTXO pool. the pool is manged to keep some number of UTXOs that have fixed fee value. The
23
+ # value is configurable by :fixed_fee. This method do the management to the pool.
24
+ def manage_utxo_pool
25
+ txb = Tapyrus::TxBuilder.new
26
+
27
+ sum, utxos = collect_outputs
28
+ return if utxos.empty?
29
+
30
+ utxos.each { |utxo| txb.add_utxo(utxo) }
31
+ address = wallet.receive_address
32
+
33
+ shortage = [fee_provider.utxo_pool_size - current_utxo_pool_size, 0].max
34
+ can_create = (sum - fee_provider.fixed_fee) / fee_provider.fixed_fee
35
+ fee_outputs_count_to_be_created = [shortage, can_create].min
36
+
37
+ return if fee_outputs_count_to_be_created == 0
38
+
39
+ fee_outputs_count_to_be_created.times do
40
+ txb.pay(address, fee_provider.fixed_fee)
41
+ end
42
+
43
+ tx = txb.change_address(address)
44
+ .fee(fee_provider.fixed_fee)
45
+ .build
46
+ tx = wallet.sign_tx(tx)
47
+ wallet.broadcast(tx, without_fee_provider: true)
48
+ ensure
49
+ status
50
+ end
51
+
52
+ # Show the status of the UTXO pool
53
+ def status
54
+ status = :ready
55
+
56
+ if current_utxo_pool_size < fee_provider.utxo_pool_size
57
+ if tpc_amount < value_to_fill_utxo_pool
58
+ status = :insufficient_amount
59
+ message = <<~MESSAGE
60
+ 1. Please replenishment TPC which is for paying fee to FeeProvider.
61
+ FeeProvider needs #{value_to_fill_utxo_pool} tapyrus at least for paying 20 transaction fees.
62
+ FeeProvider wallet's address is '#{wallet.receive_address}'
63
+ 2. Then create UTXOs for paying in UTXO pool with 'rake glueby:fee_provider:manage_utxo_pool'
64
+ MESSAGE
65
+ else
66
+ message = "Please create UTXOs for paying in UTXO pool with 'rake glueby:fee_provider:manage_utxo_pool'\n"
67
+ end
68
+ end
69
+
70
+ status = :not_ready if current_utxo_pool_size == 0
71
+
72
+ puts <<~EOS
73
+ Status: #{STATUS[status]}
74
+ TPC amount: #{delimit(tpc_amount)}
75
+ UTXO pool size: #{delimit(current_utxo_pool_size)}
76
+ #{"\n" if message}#{message}
77
+ Configuration:
78
+ fixed_fee = #{delimit(fee_provider.fixed_fee)}
79
+ utxo_pool_size = #{delimit(fee_provider.utxo_pool_size)}
80
+ EOS
81
+ end
82
+
83
+ # Show the address of Fee Provider
84
+ def address
85
+ puts wallet.receive_address
86
+ end
87
+
88
+ private
89
+
90
+ def check_wallet_amount!
91
+ if tpc_amount < fee_provider.fixed_fee
92
+ raise InsufficientTPC, <<~MESSAGE
93
+ FeeProvider has insufficient TPC to create fee outputs to fill the UTXO pool.
94
+ 1. Please replenishment TPC which is for paying fee to FeeProvider. FeeProvider needs #{fee_provider.utxo_pool_size * fee_provider.fixed_fee} tapyrus at least. FeeProvider wallet's address is '#{wallet.receive_address}'
95
+ 2. Then create UTXOs for paying in UTXO pool with 'rake glueby:fee_provider:manage_utxo_pool'
96
+ MESSAGE
97
+ end
98
+ end
99
+
100
+ def tpc_amount
101
+ wallet.balance(false)
102
+ end
103
+
104
+ def collect_outputs
105
+ wallet.list_unspent.inject([0, []]) do |sum, output|
106
+ next sum if output[:color_id] || output[:amount] == fee_provider.fixed_fee
107
+
108
+ new_sum = sum[0] + output[:amount]
109
+ new_outputs = sum[1] << {
110
+ txid: output[:txid],
111
+ script_pubkey: output[:script_pubkey],
112
+ value: output[:amount],
113
+ index: output[:vout] ,
114
+ finalized: output[:finalized]
115
+ }
116
+ return [new_sum, new_outputs] if new_sum >= value_to_fill_utxo_pool
117
+
118
+ [new_sum, new_outputs]
119
+ end
120
+ end
121
+
122
+ def current_utxo_pool_size
123
+ wallet
124
+ .list_unspent(false)
125
+ .count { |o| !o[:color_id] && o[:amount] == fee_provider.fixed_fee }
126
+ end
127
+
128
+ def value_to_fill_utxo_pool
129
+ fee_provider.fixed_fee * (fee_provider.utxo_pool_size + 1) # +1 is for paying fee
130
+ end
131
+
132
+ def wallet
133
+ fee_provider.wallet
134
+ end
135
+
136
+ def delimit(num)
137
+ num.to_s.reverse.scan(/.{1,3}/).join('_').reverse
138
+ end
139
+ end
140
+ end
136
141
  end
@@ -1,146 +1,152 @@
1
- module Glueby
2
- module Internal
3
- class Wallet
4
- # This is an abstract class for wallet adapters. If you want to use a wallet
5
- # component with Glueby modules, you can use it by adding subclass of this abstract
6
- # class for the wallet component.
7
- class AbstractWalletAdapter
8
- # Creates a new wallet inside the wallet component and returns `wallet_id`. The created
9
- # wallet is loaded from at first.
10
- # @params [String] wallet_id - Option. The wallet id that if for the wallet to be created. If this is nil, wallet adapter generates it.
11
- # @return [String] wallet_id
12
- # @raise [Glueby::Internal::Wallet::Errors::WalletAlreadyCreated] when the specified wallet has been already created.
13
- def create_wallet(wallet_id = nil)
14
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
15
- end
16
-
17
- # Delete the wallet inside the wallet component.
18
- # This method expect that the wallet will be removed completely
19
- # in the wallet and it cannot restore. It is assumed that the main use-case of
20
- # this method is for testing.
21
- #
22
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
23
- # @return [Boolean] The boolean value whether the deletion was success.
24
- def delete_wallet(wallet_id)
25
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
26
- end
27
-
28
- # Load the wallet inside the wallet component.
29
- # This method makes the wallet to possible to use on other methods like `balance`,
30
- # `list_unspent`, etc. All the methods that gets `wallet_id` as a argument needs to
31
- # load the wallet before use it.
32
- # If the wallet component doesn't need such as load operation to prepare to use the
33
- # wallet, `load_wallet` can be empty method.
34
- #
35
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
36
- # @raise [Glueby::Internal::Wallet::Errors::WalletAlreadyLoaded] when the specified wallet has been already loaded.
37
- # @raise [Glueby::Internal::Wallet::Errors::WalletNotFound] when the specified wallet is not found.
38
- def load_wallet(wallet_id)
39
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
40
- end
41
-
42
- # Unload the wallet inside the wallet component.
43
- #
44
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
45
- # @return [Boolean] The boolean value whether the unloading was success.
46
- def unload_wallet(wallet_id)
47
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
48
- end
49
-
50
- # Returns list of loaded wallet_id.
51
- #
52
- # @return [Array of String] - Array of wallet_id
53
- def wallets
54
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
55
- end
56
-
57
- # Returns amount of tapyrus that the wallet has.
58
- #
59
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
60
- # @param [Boolean] only_finalized - The balance includes only finalized UTXO value if it
61
- # is true. Default is true.
62
- # @return [Integer] The balance of the wallet. The unit is 'tapyrus'.
63
- # 1 TPC equals to 10^8 'tapyrus'.
64
- def balance(wallet_id, only_finalized = true)
65
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
66
- end
67
-
68
- # Returns all the UTXOs that the wallet has.
69
- #
70
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
71
- # @param [Boolean] only_finalized - The UTXOs includes only finalized UTXO value if it
72
- # is true. Default is true.
73
- # @return [Array of UTXO]
74
- #
75
- # ## The UTXO structure
76
- #
77
- # - txid: [String] Transaction id
78
- # - vout: [Integer] Output index
79
- # - amount: [Integer] Amount of the UTXO as tapyrus unit
80
- # - finalized: [Boolean] Whether the UTXO is finalized
81
- def list_unspent(wallet_id, only_finalized = true)
82
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
83
- end
84
-
85
- # Sign to the transaction with a key in the wallet.
86
- #
87
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
88
- # @param [Tapyrus::Tx] tx - The transaction will be signed.
89
- # @param [Array] prevtxs - array of hash that represents unbroadcasted transaction outputs used by signing tx.
90
- # Each hash has `txid`, `vout`, `scriptPubKey`, `amount` fields.
91
- # @param [Integer] sighashtype - The sighash flag for each signature that would be produced here.
92
- # @return [Tapyrus::Tx]
93
- # @raise [Glueby::Internal::Wallet::Errors::InvalidSighashType] when the specified sighashtype is invalid
94
- def sign_tx(wallet_id, tx, prevtxs = [], sighashtype: Tapyrus::SIGHASH_TYPE[:all])
95
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
96
- end
97
-
98
- # Broadcast the transaction to the Tapyrus Network.
99
- #
100
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
101
- # @param [Tapyrus::Tx] tx - The transaction to be broadcasterd.
102
- # @return [String] txid
103
- def broadcast(wallet_id, tx)
104
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
105
- end
106
-
107
- # Returns an address to receive coin.
108
- #
109
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
110
- # @return [String] P2PKH address
111
- def receive_address(wallet_id)
112
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
113
- end
114
-
115
- # Returns an address to change coin.
116
- #
117
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
118
- # @return [String] P2PKH address
119
- def change_address(wallet_id)
120
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
121
- end
122
-
123
- # Returns a new public key.
124
- #
125
- # This method is expected to returns a new public key. The key would generate internally. This key is provided
126
- # for contracts that need public key such as multi sig transaction.
127
- #
128
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
129
- # @return [Tapyrus::Key]
130
- def create_pubkey(wallet_id)
131
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
132
- end
133
-
134
- # Returns an array of addresses
135
- #
136
- # This method is expected to return the list of addresses that wallet has.
137
- #
138
- # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
139
- # @return [Array<String>] array of P2PKH address
140
- def get_addresses(wallet_id)
141
- raise NotImplementedError, "You must implement #{self.class}##{__method__}"
142
- end
143
- end
144
- end
145
- end
1
+ module Glueby
2
+ module Internal
3
+ class Wallet
4
+ # This is an abstract class for wallet adapters. If you want to use a wallet
5
+ # component with Glueby modules, you can use it by adding subclass of this abstract
6
+ # class for the wallet component.
7
+ class AbstractWalletAdapter
8
+ # Creates a new wallet inside the wallet component and returns `wallet_id`. The created
9
+ # wallet is loaded from at first.
10
+ # @params [String] wallet_id - Option. The wallet id that if for the wallet to be created. If this is nil, wallet adapter generates it.
11
+ # @return [String] wallet_id
12
+ # @raise [Glueby::Internal::Wallet::Errors::WalletAlreadyCreated] when the specified wallet has been already created.
13
+ def create_wallet(wallet_id = nil)
14
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
15
+ end
16
+
17
+ # Delete the wallet inside the wallet component.
18
+ # This method expect that the wallet will be removed completely
19
+ # in the wallet and it cannot restore. It is assumed that the main use-case of
20
+ # this method is for testing.
21
+ #
22
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
23
+ # @return [Boolean] The boolean value whether the deletion was success.
24
+ def delete_wallet(wallet_id)
25
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
26
+ end
27
+
28
+ # Load the wallet inside the wallet component.
29
+ # This method makes the wallet to possible to use on other methods like `balance`,
30
+ # `list_unspent`, etc. All the methods that gets `wallet_id` as a argument needs to
31
+ # load the wallet before use it.
32
+ # If the wallet component doesn't need such as load operation to prepare to use the
33
+ # wallet, `load_wallet` can be empty method.
34
+ #
35
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
36
+ # @raise [Glueby::Internal::Wallet::Errors::WalletAlreadyLoaded] when the specified wallet has been already loaded.
37
+ # @raise [Glueby::Internal::Wallet::Errors::WalletNotFound] when the specified wallet is not found.
38
+ def load_wallet(wallet_id)
39
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
40
+ end
41
+
42
+ # Unload the wallet inside the wallet component.
43
+ #
44
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
45
+ # @return [Boolean] The boolean value whether the unloading was success.
46
+ def unload_wallet(wallet_id)
47
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
48
+ end
49
+
50
+ # Returns list of loaded wallet_id.
51
+ #
52
+ # @return [Array of String] - Array of wallet_id
53
+ def wallets
54
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
55
+ end
56
+
57
+ # Returns amount of tapyrus that the wallet has.
58
+ #
59
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
60
+ # @param [Boolean] only_finalized - The balance includes only finalized UTXO value if it
61
+ # is true. Default is true.
62
+ # @return [Integer] The balance of the wallet. The unit is 'tapyrus'.
63
+ # 1 TPC equals to 10^8 'tapyrus'.
64
+ def balance(wallet_id, only_finalized = true)
65
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
66
+ end
67
+
68
+ # Returns the UTXOs that the wallet has.
69
+ # If label is specified, return UTXOs filtered with label
70
+ #
71
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
72
+ # @param [Boolean] only_finalized - The UTXOs includes only finalized UTXO value if it
73
+ # is true. Default is true.
74
+ # @param [String] label - Label for filtering UTXOs
75
+ # @return [Array of UTXO]
76
+ #
77
+ # ## The UTXO structure
78
+ #
79
+ # - txid: [String] Transaction id
80
+ # - vout: [Integer] Output index
81
+ # - amount: [Integer] Amount of the UTXO as tapyrus unit
82
+ # - finalized: [Boolean] Whether the UTXO is finalized
83
+ def list_unspent(wallet_id, only_finalized = true, label = nil)
84
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
85
+ end
86
+
87
+ # Sign to the transaction with a key in the wallet.
88
+ #
89
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
90
+ # @param [Tapyrus::Tx] tx - The transaction will be signed.
91
+ # @param [Array] prevtxs - array of hash that represents unbroadcasted transaction outputs used by signing tx.
92
+ # Each hash has `txid`, `vout`, `scriptPubKey`, `amount` fields.
93
+ # @param [Integer] sighashtype - The sighash flag for each signature that would be produced here.
94
+ # @return [Tapyrus::Tx]
95
+ # @raise [Glueby::Internal::Wallet::Errors::InvalidSighashType] when the specified sighashtype is invalid
96
+ def sign_tx(wallet_id, tx, prevtxs = [], sighashtype: Tapyrus::SIGHASH_TYPE[:all])
97
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
98
+ end
99
+
100
+ # Broadcast the transaction to the Tapyrus Network.
101
+ #
102
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
103
+ # @param [Tapyrus::Tx] tx - The transaction to be broadcasterd.
104
+ # @yield Option. If a block given, the block is called before actual broadcasting.
105
+ # @yieldparam [Tapyrus::Tx] tx - The tx that is going to be broadcasted as is.
106
+ # @return [String] txid
107
+ def broadcast(wallet_id, tx, &block)
108
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
109
+ end
110
+
111
+ # Returns an address to receive coin.
112
+ #
113
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
114
+ # @param [String] label The label associated with this address.
115
+ # @return [String] P2PKH address
116
+ def receive_address(wallet_id, label = nil)
117
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
118
+ end
119
+
120
+ # Returns an address to change coin.
121
+ #
122
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
123
+ # @return [String] P2PKH address
124
+ def change_address(wallet_id)
125
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
126
+ end
127
+
128
+ # Returns a new public key.
129
+ #
130
+ # This method is expected to returns a new public key. The key would generate internally. This key is provided
131
+ # for contracts that need public key such as multi sig transaction.
132
+ #
133
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
134
+ # @return [Tapyrus::Key]
135
+ def create_pubkey(wallet_id)
136
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
137
+ end
138
+
139
+ # Returns an array of addresses
140
+ #
141
+ # This method is expected to return the list of addresses that wallet has.
142
+ #
143
+ # @param [String] wallet_id - The wallet id that is offered by `create_wallet()` method.
144
+ # @param [String] label The label to filter the addresses.
145
+ # @return [Array<String>] array of P2PKH address
146
+ def get_addresses(wallet_id, label = nil)
147
+ raise NotImplementedError, "You must implement #{self.class}##{__method__}"
148
+ end
149
+ end
150
+ end
151
+ end
146
152
  end