Skip to content

Instantly share code, notes, and snippets.

@farukterzioglu
Created April 7, 2019 16:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farukterzioglu/01467b528ffeece11178cffebf6bf930 to your computer and use it in GitHub Desktop.
Save farukterzioglu/01467b528ffeece11178cffebf6bf930 to your computer and use it in GitHub Desktop.
TransferTransaction note-9
func (w *Wallet) txTransferToOutputs(address string, txHash chainhash.Hash, account uint32,
minconf int32, feeSatPerKB btcutil.Amount) (tx *txauthor.AuthoredTx, err error) {
fmt.Printf("txTransferToOutputs... \n")
chainClient, err := w.requireChainClient()
if err != nil {
return nil, err
}
var txToBoTransferred wtxmgr.Credit
err = walletdb.View(w.db, func(dbtx walletdb.ReadTx) error {
// Get current block's height and hash.
bs, err := chainClient.BlockStamp()
if err != nil {
return err
}
// Find only the transaction with hash 'txHash' that belong to 'account'
// If not found any, or the found one isn't eligible, throw a relevant exception
// Eligible if : has 'minconf' confirmation & unspent
// Eventually will return only post-dated cheques
txToBoTransferred, err = w.findTheTransaction(dbtx, txHash, account, minconf, bs)
return err
})
if err != nil {
return nil, err
}
fmt.Printf("Found : %d", txToBoTransferred.Amount)
return nil, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment