@@ -364,6 +364,10 @@ type BTCCloneCFG struct {
364
364
// into an address string. If AddressStringer is not supplied, the
365
365
// (btcutil.Address).String method will be used.
366
366
AddressStringer dexbtc.AddressStringer // btcutil.Address => string, may be an override or just the String method
367
+ // PayToAddressScript is an optional argument that can make non-standard tx
368
+ // outputs. If PayToAddressScript is not supplied the (txscript).PayToAddrScript
369
+ // method will be used. Note the extra paramaeter for a string address.
370
+ PayToAddressScript func (btcutil.Address , string ) ([]byte , error )
367
371
// BlockDeserializer can be used in place of (*wire.MsgBlock).Deserialize.
368
372
BlockDeserializer func ([]byte ) (* wire.MsgBlock , error )
369
373
// ArglessChangeAddrRPC can be true if the getrawchangeaddress takes no
@@ -801,6 +805,7 @@ type baseWallet struct {
801
805
localFeeRate func (context.Context , RawRequester , uint64 ) (uint64 , error )
802
806
feeCache * feeRateCache
803
807
decodeAddr dexbtc.AddressDecoder
808
+ payToAddress func (btcutil.Address , string ) ([]byte , error )
804
809
walletDir string
805
810
806
811
deserializeTx func ([]byte ) (* wire.MsgTx , error )
@@ -1317,6 +1322,13 @@ func newUnconnectedWallet(cfg *BTCCloneCFG, walletCfg *WalletConfig) (*baseWalle
1317
1322
}
1318
1323
}
1319
1324
1325
+ addressPayer := cfg .PayToAddressScript
1326
+ if addressPayer == nil {
1327
+ addressPayer = func (addr btcutil.Address , _ string ) ([]byte , error ) {
1328
+ return txscript .PayToAddrScript (addr )
1329
+ }
1330
+ }
1331
+
1320
1332
w := & baseWallet {
1321
1333
symbol : cfg .Symbol ,
1322
1334
chainParams : cfg .ChainParams ,
@@ -1336,6 +1348,7 @@ func newUnconnectedWallet(cfg *BTCCloneCFG, walletCfg *WalletConfig) (*baseWalle
1336
1348
feeCache : feeCache ,
1337
1349
decodeAddr : addrDecoder ,
1338
1350
stringAddr : addrStringer ,
1351
+ payToAddress : addressPayer ,
1339
1352
walletInfo : cfg .WalletInfo ,
1340
1353
deserializeTx : txDeserializer ,
1341
1354
serializeTx : txSerializer ,
@@ -4505,7 +4518,7 @@ func (btc *baseWallet) send(address string, val uint64, feeRate uint64, subtract
4505
4518
if err != nil {
4506
4519
return nil , 0 , 0 , fmt .Errorf ("invalid address: %s" , address )
4507
4520
}
4508
- pay2script , err := txscript . PayToAddrScript (addr )
4521
+ pay2script , err := btc . payToAddress (addr , address )
4509
4522
if err != nil {
4510
4523
return nil , 0 , 0 , fmt .Errorf ("PayToAddrScript error: %w" , err )
4511
4524
}
0 commit comments