Class: Round::Transaction

Inherits:
Base
  • Object
show all
Defined in:
lib/round/transaction.rb

Instance Attribute Summary

Attributes inherited from Base

#resource

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

association, #hash_identifier, #initialize, #method_missing, #refresh

Constructor Details

This class inherits a constructor from Round::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Round::Base

Class Method Details

.hash_identifierObject



31
32
33
# File 'lib/round/transaction.rb', line 31

def self.hash_identifier
  'hash'
end

Instance Method Details

#approve(mfa_token) ⇒ Object



22
23
24
25
# File 'lib/round/transaction.rb', line 22

def approve(mfa_token)
  @client.context.mfa_token = mfa_token
  @resource.approve({})
end

#sign(wallet, redirect_uri: nil, network:) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/round/transaction.rb', line 4

def sign(wallet, redirect_uri: nil, network:)
  raise 'transaction is already signed' unless @resource['status'] == 'unsigned'
  raise 'a wallet is required to sign a transaction' unless wallet
  network = :testnet3 if network == :bitcoin_testnet

  transaction = CoinOp::Bit::Transaction.data(@resource, network: network)
  raise 'bad change address' unless wallet.valid_output?(transaction.outputs.last)
  
  @resource = @resource.update( 
     signatures: {
       transaction_hash: transaction.hex_hash,
       inputs: wallet.signatures(transaction)
     },
     redirect_uri: redirect_uri
  )
  self
end

#transaction_hashObject



27
28
29
# File 'lib/round/transaction.rb', line 27

def transaction_hash
  @resource[:hash]
end