use of com.sparrowwallet.drongo.psbt.PSBTInput in project drongo by sparrowwallet.
the class PSBT method combine.
public void combine(PSBT psbt) {
byte[] txBytes = transaction.bitcoinSerialize();
byte[] psbtTxBytes = psbt.getTransaction().bitcoinSerialize();
if (!Arrays.equals(txBytes, psbtTxBytes)) {
throw new IllegalArgumentException("Provided PSBT does contain a matching global transaction");
}
if (isFinalized() || psbt.isFinalized()) {
throw new IllegalArgumentException("Cannot combine an already finalised PSBT");
}
if (psbt.getVersion() != null) {
version = psbt.getVersion();
}
extendedPublicKeys.putAll(psbt.extendedPublicKeys);
globalProprietary.putAll(psbt.globalProprietary);
for (int i = 0; i < getPsbtInputs().size(); i++) {
PSBTInput thisInput = getPsbtInputs().get(i);
PSBTInput otherInput = psbt.getPsbtInputs().get(i);
thisInput.combine(otherInput);
}
for (int i = 0; i < getPsbtOutputs().size(); i++) {
PSBTOutput thisOutput = getPsbtOutputs().get(i);
PSBTOutput otherOutput = psbt.getPsbtOutputs().get(i);
thisOutput.combine(otherOutput);
}
}
use of com.sparrowwallet.drongo.psbt.PSBTInput in project drongo by sparrowwallet.
the class FinalizingPSBTWallet method getSignedKeystores.
@Override
public Map<PSBTInput, Map<TransactionSignature, Keystore>> getSignedKeystores(PSBT psbt) {
Map<PSBTInput, Map<TransactionSignature, Keystore>> signedKeystores = new LinkedHashMap<>();
for (PSBTInput psbtInput : psbt.getPsbtInputs()) {
List<TransactionSignature> signatures = new ArrayList<>(psbtInput.getSignatures());
Map<TransactionSignature, Keystore> signatureKeystoreMap = new LinkedHashMap<>();
for (int i = 0; i < signatures.size(); i++) {
signatureKeystoreMap.put(signatures.get(i), new Keystore("Keystore " + (i + 1)));
}
signedKeystores.put(psbtInput, signatureKeystoreMap);
}
return signedKeystores;
}
Aggregations