Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UtxoCoinAccount: make some functions public #267

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
39 changes: 19 additions & 20 deletions src/GWallet.Backend/UtxoCoin/UtxoCoinAccount.fs
Expand Up @@ -22,7 +22,7 @@ type internal TransactionOutpoint =
member self.ToCoin (): Coin =
Coin(self.Transaction, uint32 self.OutputIndex)

type internal IUtxoAccount =
type IUtxoAccount =
inherit IAccount

abstract member PublicKey: PubKey with get
Expand Down Expand Up @@ -77,7 +77,7 @@ module Account =
.GetScriptPubKey(ScriptPubKeyType.SegwitP2SH)
.GetDestinationAddress(GetNetwork currency)

let internal GetNativeSegwitPublicAddressFromPublicKey currency (publicKey: PubKey): BitcoinAddress =
let GetNativeSegwitPublicAddressFromPublicKey currency (publicKey: PubKey): BitcoinAddress =
publicKey
.GetScriptPubKey(ScriptPubKeyType.Segwit)
.GetDestinationAddress(GetNetwork currency)
Expand Down Expand Up @@ -210,11 +210,11 @@ module Account =
//so this is unreachable.
failwith "Unreachable: unrecognized scriptPubKey"

let private CreateTransactionAndCoinsToBeSigned (account: IUtxoAccount)
(transactionInputs: List<TransactionInputOutpointInfo>)
(destination: string)
(amount: TransferAmount)
: TransactionBuilder =
let CreateTransactionAndCoinsToBeSigned (account: IUtxoAccount)
(transactionInputs: List<TransactionInputOutpointInfo>)
(destination: string)
(amount: TransferAmount)
: TransactionBuilder =
let coins = List.map (ConvertToICoin account) transactionInputs

let transactionBuilder = (GetNetwork account.Currency).CreateTransactionBuilder()
Expand Down Expand Up @@ -449,7 +449,7 @@ module Account =
failwith <| SPrintF1 "Something went wrong when verifying transaction: %A" errors
finalTransaction

let internal GetPrivateKey (account: NormalAccount) password =
let GetPrivateKey (account: NormalAccount) password =
let encryptedPrivateKey = account.GetEncryptedPrivateKey()
let encryptedSecret = BitcoinEncryptedSecretNoEC(encryptedPrivateKey, GetNetwork (account:>IAccount).Currency)
try
Expand All @@ -458,11 +458,11 @@ module Account =
| :? SecurityException ->
raise (InvalidPassword)

let internal SignTransaction (account: NormalUtxoAccount)
(txMetadata: TransactionMetadata)
(destination: string)
(amount: TransferAmount)
(password: string) =
let SignTransaction (account: NormalUtxoAccount)
(txMetadata: TransactionMetadata)
(destination: string)
(amount: TransferAmount)
(password: string) =

let privateKey = GetPrivateKey account password

Expand Down Expand Up @@ -521,13 +521,12 @@ module Account =
// and show the info from the RawTx, using NBitcoin to extract it
BroadcastRawTransaction currency transaction.RawTransaction

let internal SendPayment (account: NormalUtxoAccount)
(txMetadata: TransactionMetadata)
(destination: string)
(amount: TransferAmount)
(password: string)
(ignoreHigherMinerFeeThanAmount: bool)
=
let SendPayment (account: NormalUtxoAccount)
(txMetadata: TransactionMetadata)
(destination: string)
(amount: TransferAmount)
(password: string)
(ignoreHigherMinerFeeThanAmount: bool) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aarani nit: fantomas doesn't put the equals sign there 😅

let baseAccount = account :> IAccount
if (baseAccount.PublicAddress.Equals(destination, StringComparison.InvariantCultureIgnoreCase)) then
raise DestinationEqualToOrigin
Expand Down