mirror of
https://github.com/LBRYFoundation/lbcutil.git
synced 2025-08-23 17:47:30 +00:00
This is consistent with the rest of the code base. i.e.: base58/bloom/hash160/hdkeychain.
43 lines
679 B
Go
43 lines
679 B
Go
package btcutil_test
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
|
|
. "github.com/btcsuite/btcutil"
|
|
)
|
|
|
|
func ExampleNewAmount() {
|
|
amountOne, err := NewAmount(1)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(amountOne) //Output 1
|
|
|
|
amountFraction, err := NewAmount(0.01234567)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(amountFraction) //Output 2
|
|
|
|
amountZero, err := NewAmount(0)
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(amountZero) //Output 3
|
|
|
|
amountNaN, err := NewAmount(math.NaN())
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
fmt.Println(amountNaN) //Output 4
|
|
|
|
// Output: 1 BTC
|
|
// 0.01234567 BTC
|
|
// 0 BTC
|
|
// invalid bitcoin amount
|
|
}
|