mirror of
https://github.com/btcsuite/btcd.git
synced 2026-08-13 12:32:51 +02:00
Merge pull request #2563 from starius/psbt-oom
psbt: compact witness utxo scripts after parsing
This commit is contained in:
commit
aa108a28ff
2 changed files with 10 additions and 1 deletions
|
|
@ -240,7 +240,9 @@ func TestParsesWitnessUtxoTxOutStrictly(t *testing.T) {
|
|||
strictnessPSBTWithWitnessUtxo(t, txOutBytes),
|
||||
), false)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, pkScript, packet.Inputs[0].WitnessUtxo.PkScript)
|
||||
script := packet.Inputs[0].WitnessUtxo.PkScript
|
||||
require.Equal(t, pkScript, script)
|
||||
require.Equal(t, len(script), cap(script))
|
||||
|
||||
malformedTxOut := append(append([]byte{}, txOutBytes...), 0x00)
|
||||
_, err = NewFromRawBytes(bytes.NewReader(
|
||||
|
|
|
|||
|
|
@ -315,6 +315,13 @@ func readTxOut(txout []byte) (*wire.TxOut, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// wire.ReadTxOut stores PkScript in an internal 4 MiB script slab.
|
||||
// Compact it before storing the TxOut in the PSBT so tiny witness
|
||||
// scripts do not retain the full slab.
|
||||
script := make([]byte, len(txOut.PkScript))
|
||||
copy(script, txOut.PkScript)
|
||||
txOut.PkScript = script
|
||||
|
||||
return txOut, nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue