• R/O
  • HTTP
  • SSH
  • HTTPS

vapor: Commit

Golang implemented sidechain for Bytom


Commit MetaInfo

Revision59604bb58439492fc242f4e5739c8ac528523496 (tree)
Time2019-07-12 11:20:25
Authoroys <oys@oysd...>
Commiteroys

Log Message

optimise

Change Summary

Incremental Difference

--- a/wallet/annotated.go
+++ b/wallet/annotated.go
@@ -192,11 +192,10 @@ func (w *Wallet) BuildAnnotatedInput(tx *types.Tx, i uint32) *query.AnnotatedInp
192192 }
193193
194194 func (w *Wallet) getAddressFromControlProgram(prog []byte, isMainchain bool) string {
195- netParams := &consensus.ActiveNetParams
195+ var netParams interface{}
196+ netParams = &consensus.ActiveNetParams
196197 if isMainchain {
197- netParams := new(consensus.Params)
198- netParams.Name = btmConsensus.MainNetParams.Name
199- netParams.Bech32HRPSegwit = btmConsensus.MainNetParams.Bech32HRPSegwit
198+ netParams = &btmConsensus.MainNetParams
200199 }
201200
202201 if segwit.IsP2WPKHScript(prog) {
@@ -218,18 +217,16 @@ func BuildP2PKHAddress(pubHash []byte, netParams interface{}) string {
218217 case *consensus.Params:
219218 params := netParams.(*consensus.Params)
220219 address, err := common.NewAddressWitnessPubKeyHash(pubHash, params)
221- if err != nil {
222- return ""
220+ if err == nil {
221+ return address.EncodeAddress()
223222 }
224- return address.EncodeAddress()
225223
226224 case *btmConsensus.Params:
227225 params := netParams.(*btmConsensus.Params)
228226 address, err := btmCommon.NewAddressWitnessPubKeyHash(pubHash, params)
229- if err != nil {
230- return ""
227+ if err == nil {
228+ return address.EncodeAddress()
231229 }
232- return address.EncodeAddress()
233230 }
234231 return ""
235232 }
@@ -240,18 +237,16 @@ func BuildP2SHAddress(scriptHash []byte, netParams interface{}) string {
240237 case *consensus.Params:
241238 params := netParams.(*consensus.Params)
242239 address, err := common.NewAddressWitnessScriptHash(scriptHash, params)
243- if err != nil {
244- return ""
240+ if err == nil {
241+ return address.EncodeAddress()
245242 }
246- return address.EncodeAddress()
247243
248244 case *btmConsensus.Params:
249245 params := netParams.(*btmConsensus.Params)
250246 address, err := btmCommon.NewAddressWitnessScriptHash(scriptHash, params)
251- if err != nil {
252- return ""
247+ if err == nil {
248+ return address.EncodeAddress()
253249 }
254- return address.EncodeAddress()
255250 }
256251 return ""
257252 }
Show on old repository browser