mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-18 21:32:35 +01:00
ScriptBuilder: extract private helper p2whOutputScript()
This commit is contained in:
parent
15ee38aae0
commit
a1237a636b
@ -317,16 +317,20 @@ public class ScriptBuilder {
|
||||
else
|
||||
throw new IllegalStateException("Cannot handle " + scriptType);
|
||||
} else if (to instanceof SegwitAddress) {
|
||||
// OP_0 <pubKeyHash|scriptHash>
|
||||
SegwitAddress toSegwit = (SegwitAddress) to;
|
||||
smallNum(toSegwit.getWitnessVersion());
|
||||
data(toSegwit.getWitnessProgram());
|
||||
p2whOutputScript((SegwitAddress) to);
|
||||
} else {
|
||||
throw new IllegalStateException("Cannot handle " + to);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private ScriptBuilder p2whOutputScript(SegwitAddress address) {
|
||||
checkState(chunks.isEmpty());
|
||||
// OP_0 <pubKeyHash|scriptHash>
|
||||
return smallNum(address.getWitnessVersion())
|
||||
.data(address.getWitnessProgram());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a scriptSig that can redeem a P2PKH output.
|
||||
* If given signature is null, incomplete scriptSig will be created with OP_0 instead of signature
|
||||
|
Loading…
Reference in New Issue
Block a user