-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package main | ||
|
||
import ( | ||
"log" | ||
|
||
"github.com/tonicpow/go-minercraft" | ||
) | ||
|
||
func main() { | ||
|
||
// Create a new client | ||
client, err := minercraft.NewClient(nil, nil) | ||
if err != nil { | ||
log.Fatalf("error occurred: %s", err.Error()) | ||
} | ||
|
||
// Select the miner | ||
miner := client.MinerByName(minercraft.MinerTaal) | ||
|
||
// Get a fee quote from a miner | ||
var response *minercraft.FeeQuoteResponse | ||
if response, err = client.FeeQuote(miner); err != nil { | ||
log.Fatalf("error occurred: %s", err.Error()) | ||
} | ||
|
||
// Example Tx Size (computed from the rawTx.ToBytes()) | ||
txSizeInBytes := uint64(441) // The Tx is 441 bytes in size, let's get the fee for that Tx | ||
|
||
// Get the fee for a specific tx size (for mining and for data) | ||
var fee uint64 | ||
if fee, err = response.Quote.CalculateFee(minercraft.FeeCategoryMining, minercraft.FeeTypeStandard, txSizeInBytes); err != nil { | ||
log.Fatalf("error occurred: %s", err.Error()) | ||
} | ||
|
||
// Display the results | ||
log.Printf("miner: %s", response.Miner.Name) | ||
log.Printf("tx size in bytes: %d and mining fee: %d", txSizeInBytes, fee) | ||
} |