本文整理汇总了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
}