mirror of
https://github.com/bitcoin-s/bitcoin-s.git
synced 2025-02-23 14:50:42 +01:00
Adding 'FundingInfo' abstract class to pair together unsignedTxs and the utxos used to fund them
rename 'unsignedTx' -> 'transaction' in FundingInfo trait
This commit is contained in:
parent
4e938065f2
commit
9e149e9efb
3 changed files with 45 additions and 6 deletions
|
@ -60,12 +60,13 @@ sealed trait BlockHeader extends NetworkElement {
|
|||
|
||||
def merkleRootHash: DoubleSha256Digest
|
||||
|
||||
/** Returns the merkle root hash in BIG ENDIAN format. This is not compatible with the bitcoin
|
||||
* protocol but it is useful for rpc clients and block explorers
|
||||
* See this link for more info
|
||||
* [[https://bitcoin.stackexchange.com/questions/2063/why-does-the-bitcoin-protocol-use-the-little-endian-notation]]
|
||||
* @return
|
||||
*/
|
||||
/**
|
||||
* Returns the merkle root hash in BIG ENDIAN format. This is not compatible with the bitcoin
|
||||
* protocol but it is useful for rpc clients and block explorers
|
||||
* See this link for more info
|
||||
* [[https://bitcoin.stackexchange.com/questions/2063/why-does-the-bitcoin-protocol-use-the-little-endian-notation]]
|
||||
* @return
|
||||
*/
|
||||
def merkleRootHashBE: DoubleSha256Digest = merkleRootHash.flip
|
||||
|
||||
/**
|
||||
|
|
|
@ -21,4 +21,7 @@ trait Factory[T] {
|
|||
def apply(hex: String): T = fromHex(hex)
|
||||
|
||||
def logger: Logger = BitcoinSLogger.logger
|
||||
|
||||
/** Allows a `def foo[C: Factory]()` construction. */
|
||||
implicit def self: Factory[T] = this
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package org.bitcoins.core.wallet.signer
|
||||
|
||||
import org.bitcoins.core.protocol.transaction.{ BaseTransaction, Transaction, WitnessTransaction }
|
||||
import org.bitcoins.core.wallet.utxo.{ BitcoinUTXOSpendingInfo, UTXOSpendingInfo }
|
||||
|
||||
/**
|
||||
* This meant to represent the class used to 'fund' an
|
||||
* unsigned [[Transaction]].
|
||||
* This is useful for when we have multiple [[org.bitcoins.core.config.NetworkParameters]]
|
||||
* that each have their own transaction type. I.e. we should only be able to have
|
||||
* BitcoinTransactions paired with [[BitcoinUTXOSpendingInfo]], the same would apply for litecoin etc.
|
||||
*/
|
||||
sealed abstract class FundingInfo {
|
||||
/** The transaction we are funding with the utxos */
|
||||
def transaction: Transaction
|
||||
/** The utxos used to fund the tx */
|
||||
def utxos: Seq[UTXOSpendingInfo]
|
||||
}
|
||||
|
||||
sealed abstract class BitcoinFundingInfo extends FundingInfo {
|
||||
override def utxos: Seq[BitcoinUTXOSpendingInfo]
|
||||
}
|
||||
|
||||
object BitcoinFundingInfo {
|
||||
private case class BitcoinFundingInfoImpl(
|
||||
transaction: Transaction,
|
||||
utxos: Seq[BitcoinUTXOSpendingInfo]) extends BitcoinFundingInfo
|
||||
def apply(tx: BaseTransaction, utxos: Seq[BitcoinUTXOSpendingInfo]): BitcoinFundingInfo = {
|
||||
BitcoinFundingInfoImpl(tx, utxos)
|
||||
}
|
||||
|
||||
def apply(wtx: WitnessTransaction, utxos: Seq[BitcoinUTXOSpendingInfo]): BitcoinFundingInfo = {
|
||||
BitcoinFundingInfoImpl(wtx, utxos)
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue