本文整理匯總了Golang中github.com/btcsuite/btcutil.Address.ScriptAddress方法的典型用法代碼示例。如果您正苦於以下問題:Golang Address.ScriptAddress方法的具體用法?Golang Address.ScriptAddress怎麽用?Golang Address.ScriptAddress使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/btcsuite/btcutil.Address
的用法示例。
在下文中一共展示了Address.ScriptAddress方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: FetchHistory2
func (l *LibbitcoinClient) FetchHistory2(address btc.Address, fromHeight uint32, callback func(interface{}, error)) {
hash160 := address.ScriptAddress()
var netID byte
height := make([]byte, 4)
binary.LittleEndian.PutUint32(height, fromHeight)
address.ScriptAddress()
switch reflect.TypeOf(address).String() {
case "*btcutil.AddressPubKeyHash":
if l.Params.Name == chaincfg.MainNetParams.Name {
netID = byte(0)
} else {
netID = byte(111)
}
case "*btcutil.AddressScriptHash":
if l.Params.Name == chaincfg.MainNetParams.Name {
netID = byte(5)
} else {
netID = byte(196)
}
}
req := []byte{}
req = append(req, netID)
req = append(req, hash160...)
req = append(req, height...)
go l.SendCommand("address.fetch_history2", req, callback)
}
示例2: RenewSubscription
func (l *LibbitcoinClient) RenewSubscription(address btc.Address, callback func(interface{})) {
req := []byte{}
req = append(req, byte(0))
req = append(req, byte(160))
req = append(req, address.ScriptAddress()...)
go l.SendCommand("address.renew", req, nil)
l.lock.Lock()
l.subscriptions[address.String()] = subscription{
expiration: time.Now().Add(24 * time.Hour),
callback: callback,
}
l.lock.Unlock()
}
示例3: PayToAddrScript
// PayToAddrScript creates a new script to pay a transaction output to a the
// specified address.
func PayToAddrScript(addr btcutil.Address) ([]byte, error) {
switch addr := addr.(type) {
case *btcutil.AddressPubKeyHash:
if addr == nil {
return nil, ErrUnsupportedAddress
}
return payToPubKeyHashScript(addr.ScriptAddress())
case *btcutil.AddressScriptHash:
if addr == nil {
return nil, ErrUnsupportedAddress
}
return payToScriptHashScript(addr.ScriptAddress())
case *btcutil.AddressPubKey:
if addr == nil {
return nil, ErrUnsupportedAddress
}
return payToPubKeyScript(addr.ScriptAddress())
}
return nil, ErrUnsupportedAddress
}