Search in sources :

Example 16 with PSBTInput

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);
    }
}
Also used : PSBTOutput(com.sparrowwallet.drongo.psbt.PSBTOutput) PSBTInput(com.sparrowwallet.drongo.psbt.PSBTInput)

Example 17 with PSBTInput

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;
}
Also used : PSBTInput(com.sparrowwallet.drongo.psbt.PSBTInput)

Aggregations

PSBTInput (com.sparrowwallet.drongo.psbt.PSBTInput)17 PSBTOutput (com.sparrowwallet.drongo.psbt.PSBTOutput)6 ECKey (com.sparrowwallet.drongo.crypto.ECKey)5 Address (com.sparrowwallet.drongo.address.Address)3 com.sparrowwallet.drongo.protocol (com.sparrowwallet.drongo.protocol)3 PSBT (com.sparrowwallet.drongo.psbt.PSBT)3 Subscribe (com.google.common.eventbus.Subscribe)2 PSBTEntry (com.sparrowwallet.drongo.psbt.PSBTEntry)2 EventManager (com.sparrowwallet.sparrow.EventManager)2 com.sparrowwallet.sparrow.control (com.sparrowwallet.sparrow.control)2 com.sparrowwallet.sparrow.event (com.sparrowwallet.sparrow.event)2 StandardCharsets (java.nio.charset.StandardCharsets)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 FXML (javafx.fxml.FXML)2 Initializable (javafx.fxml.Initializable)2 javafx.scene.control (javafx.scene.control)2 Field (tornadofx.control.Field)2 Fieldset (tornadofx.control.Fieldset)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 com.sparrowwallet.drongo (com.sparrowwallet.drongo)1